Esempio 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();
        }
        public EzyAppSetup setupApp(String appName)
        {
            EzyAppSetup appSetup = null;

            if (appSetups.ContainsKey(appName))
            {
                appSetup = appSetups[appName];
            }
            else
            {
                EzyAppDataHandlers dataHandlers = handlerManager.getAppDataHandlers(appName);
                appSetup           = new EzySimpleAppSetup(dataHandlers, this);
                appSetups[appName] = appSetup;
            }
            return(appSetup);
        }