Skip to content

a socket server supports both tcp socket and websocket protocols

License

Notifications You must be signed in to change notification settings

communityus-branch/ezyfox-server

 
 

Repository files navigation

ezyfox-server

Synopsis

Ezyfox server is a socket server. It supports both tcp socket and websocket. It also provides manipulation beans, auto binding, auto implementation and more utilities.

Code Example

1. Create an app entry

public class EzyChatEntryLoader extends EzyAbstractAppEntryLoader {

	@Override
	public EzyAppEntry load() throws Exception {
		return new EzyChatEntry();
	}
	
}

2. Create bean context

private EzyBeanContext createBeanContext(
			EzyPluginContext context, EzyApply<EzyBeanContextBuilder> applier) {
    	EzyBindingContext bindingContext = createBindingContext();
    	EzyMarshaller marshaller = bindingContext.newMarshaller();
    	EzyUnmarshaller unmarshaller = bindingContext.newUnmarshaller();
    	EzyBeanContextBuilder beanContextBuilder = EzyBeanContext.builder()
    			.addSingleton("pluginContext", context)
    			.addSingleton("marshaller", marshaller)
    			.addSingleton("unmarshaller", unmarshaller)
    			.scan("vn.team.freechat.plugin")
    			.scan("vn.team.freechat.common.repo")
    			.scan("vn.team.freechat.common.service");
    	
    	applier.apply(beanContextBuilder);

		return beanContextBuilder.build();
}

3. Auto implementation

@EzyAutoImpl
public interface EzyChatMessageRepo 
	extends EzyMongoRepository<ObjectId, EzyChatMessage> {

}

4. Auto binding

@EzyPrototype(properties = { @EzyKeyValue(key = "type", value = "REQUEST_HANDLER"),
		@EzyKeyValue(key = "cmd", value = "2") })
@EzyArrayBinding(indexes = { "message", "receiver" })
@Setter
public class EzyChatUserRequestHandler extends EzyClientRequestHandler implements EzyDataBinding {

	private String message;
	private String receiver;

	@EzyAutoBind
	private EzyChatMessageRepo ezyChatMessageRepo;

	@EzyAutoBind
	private EzyResponseFactory responseFactory;
}

5. Auto serialize

@Getter
@Setter
@EzyObjectBinding(read = false)
public class EzyChatError {

	private final int code;
	private final String message;
	
}

Motivation

We are game server developers, We have a lot of online games and We must buy game server engine like SmarfoxServer or Photon but they are really expensive. We need make a change to help us and everyone. Free is good idea and We make Ezyfox server

API Reference

Tests

mvn test

Contributors

  • Project development
  • Project admin tools development

License

  • Apache License, Version 2.0

About

a socket server supports both tcp socket and websocket protocols

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 61.0%
  • JavaScript 20.2%
  • CSS 16.6%
  • HTML 1.1%
  • FreeMarker 0.8%
  • Shell 0.1%
  • Other 0.2%