Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Thread.CurrentThread.Name = "main";

            new BindingExample().Run();
            new EntityExample().Run();
            new DateTimeExample().Run();

            EzyLoggerFactory.setLoggerLevel(EzyLoggerLevel.DEBUG);

            EzyClientConfig clientConfig = EzyClientConfig
                                           .builder()
                                           .clientName("freetanks")
                                           .zoneName("example")
                                           .build();
            EzyClients clients = EzyClients.getInstance();
            //EzyClient client = clients.newDefaultClient(clientConfig);
            EzyClient client = new EzyUTClient(clientConfig);

            clients.addClient(client);
            EzySetup setup = client.setup();

            setup.addEventHandler(EzyEventType.CONNECTION_SUCCESS, new EzyConnectionSuccessHandler());
            setup.addEventHandler(EzyEventType.CONNECTION_FAILURE, new EzyConnectionFailureHandler());
            setup.addEventHandler(EzyEventType.DISCONNECTION, new EzyDisconnectionHandler());
            setup.addDataHandler(EzyCommand.HANDSHAKE, new ExHandshakeEventHandler());
            setup.addDataHandler(EzyCommand.LOGIN, new ExLoginSuccessHandler());
            //setup.addDataHandler(EzyCommand.LOGIN_ERROR, new ExLoginErrorHandler());
            setup.addDataHandler(EzyCommand.APP_ACCESS, new ExAccessAppHandler());
            setup.addDataHandler(EzyCommand.UDP_HANDSHAKE, new UdpHandshakeHandler());

            EzyAppSetup appSetup = setup.setupApp("hello-world");

            //appSetup.addDataHandler(Commands.ERROR, new ErrorResponseHandler());
            appSetup.addDataHandler(Commands.ACCESS_LOBBY_ROOM, new AccessLobbyResponseHandler());
            appSetup.addDataHandler(Commands.ROOM_INFO, new RoomInfoResponseHandler());
            appSetup.addDataHandler(Commands.SYNC_POSITION, new SyncPositionHandler());

            client.connect("ws.tvd12.com", 3005);
            //client.connect("127.0.0.1", 3005);

            int time = 0;

            while (true)
            {
                Thread.Sleep(3);
                client.processEvents();
                time += 3;
                if (time > 5000)
                {
                    //client.disconnect(401);
                    time = 0;
                    //break;
                }
            }

            //mainEventsLoopTest();
        }
Exemplo n.º 2
0
 public EzyTcpClient(EzyClientConfig config)
 {
     this.config             = config;
     this.name               = config.getClientName();
     this.status             = EzyConnectionStatus.NULL;
     this.status             = EzyConnectionStatus.NULL;
     this.pingManager        = new EzySimplePingManager(config.getPing());
     this.pingSchedule       = new EzyPingSchedule(this);
     this.handlerManager     = new EzySimpleHandlerManager(this);
     this.networkStatistics  = new EzySimpleStatistics();
     this.requestSerializer  = new EzySimpleRequestSerializer();
     this.settingUp          = new EzySimpleSetup(handlerManager);
     this.unloggableCommands = newUnloggableCommands();
     this.socketClient       = newSocketClient();
     this.logger             = EzyLoggerFactory.getLogger(GetType());
 }
Exemplo n.º 3
0
 public EzySimplePluginSetup(EzyPluginDataHandlers dataHandlers, EzySetup parent)
 {
     this.parent       = parent;
     this.dataHandlers = dataHandlers;
 }
 public EzySimpleAppSetup(EzyAppDataHandlers dataHandlers, EzySetup parent)
 {
     this.parent       = parent;
     this.dataHandlers = dataHandlers;
 }