Exemple #1
0
        public override void handle(EzyArray data)
        {
            int      appId        = data.get <int>(0);
            EzyArray commandData  = data.get <EzyArray>(1);
            String   cmd          = commandData.get <String>(0);
            EzyData  responseData = commandData.get <EzyData>(1, null);

            EzyApp app = client.getAppById(appId);

            if (app == null)
            {
                logger.info("receive message when has not joined app yet");
                return;
            }
            EzyAppDataHandler dataHandler = app.getDataHandler(cmd);

            if (dataHandler != null)
            {
                dataHandler.handle(app, responseData);
            }
            else
            {
                logger.warn("app: " + app.getName() + " has no handler for command: " + cmd);
            }
        }
        public override void handle(EzyArray data)
        {
            int      pluginId     = data.get <int>(0);
            EzyArray commandData  = data.get <EzyArray>(1);
            String   cmd          = commandData.get <String>(0);
            EzyData  responseData = commandData.get <EzyData>(1, null);

            EzyPlugin plugin = client.getPluginById(pluginId);

            if (plugin == null)
            {
                logger.info("receive message when has not joined plugin yet");
                return;
            }
            EzyPluginDataHandler dataHandler = plugin.getDataHandler(cmd);

            if (dataHandler != null)
            {
                dataHandler.handle(plugin, responseData);
            }
            else
            {
                logger.warn("plugin: " + plugin.getName() + " has no handler for command: " + cmd);
            }
        }
        protected virtual EzyUser newUser(EzyArray data)
        {
            long          userId   = data.get <long>(2);
            String        username = data.get <String>(3);
            EzySimpleUser user     = new EzySimpleUser(userId, username);

            return(user);
        }
        protected virtual EzyPlugin newPlugin(EzyZone zone, EzyArray data)
        {
            int             pluginId   = data.get <int>(0);
            String          pluginName = data.get <String>(1);
            EzySimplePlugin plugin     = new EzySimplePlugin(zone, pluginId, pluginName);

            return(plugin);
        }
Exemple #5
0
        protected virtual EzyApp newApp(EzyZone zone, EzyArray data)
        {
            int          appId   = data.get <int>(0);
            String       appName = data.get <String>(1);
            EzySimpleApp app     = new EzySimpleApp(zone, appId, appName);

            return(app);
        }
        protected virtual EzyZone newZone(EzyArray data)
        {
            int           zoneId   = data.get <int>(0);
            String        zoneName = data.get <String>(1);
            EzySimpleZone zone     = new EzySimpleZone(client, zoneId, zoneName);

            return(zone);
        }
        public override void handle(EzyArray data)
        {
            EzyZone       zone       = client.getZone();
            EzyAppManager appManager = zone.getAppManager();
            int           appId      = data.get <int>(0);
            int           reasonId   = data.get <int>(1);
            EzyApp        app        = appManager.removeApp(appId);

            if (app != null)
            {
                postHandle(app, data);
                logger.info("user exit app: " + app + ", reason: " + reasonId);
            }
        }
Exemple #8
0
        public EzySimpleResponse(EzyArray data)
        {
            this.data = data;
            int cmdId = data.get <int>(0);

            this.command   = (EzyCommand)cmdId;
            this.timestamp = DateTime.Now;
        }
        protected void processReceivedMessage(EzyArray message)
        {
            int        cmdId = message.get <int>(0);
            EzyArray   data  = message.get <EzyArray>(1, null);
            EzyCommand cmd   = (EzyCommand)cmdId;

            printReceivedData(cmd, data);
            if (cmd == EzyCommand.DISCONNECT)
            {
                int reasonId = data.get <int>(0);
                disconnectReason = reasonId;
                socketStatuses.push(EzySocketStatus.DISCONNECTING);
            }
            else
            {
                dataHandlers.handle(cmd, data);
            }
        }
Exemple #10
0
        public IList <T> unmarshallList <T>(EzyArray array)
        {
            List <T> answer = new List <T>();

            for (int i = 0; i < array.size(); ++i)
            {
                answer.Add(unmarshall <T>(array.get <object>(i)));
            }
            return(answer);
        }
        public override void handle(EzyArray data)
        {
            EzyData responseData = data.get <EzyData>(4);
            EzyUser user         = newUser(data);
            EzyZone zone         = newZone(data);

            ((EzyMeAware)client).setMe(user);
            ((EzyZoneAware)client).setZone(zone);
            handleLoginSuccess(responseData);
            logger.debug("user: "******" logged in successfully");
        }
        protected byte[] parseArray(EzyArray array)
        {
            int index = 1;
            int size  = array.size();

            byte[][] bytess = new byte[size + 1][];
            bytess[0] = parseArraySize(size);
            for (int i = 0; i < size; i++)
            {
                bytess[index++] = serialize(array.get <Object>(i));
            }
            return(EzyBytes.merge(bytess));
        }
        public override void handle(EzyArray data)
        {
            int               responseCode = data.get <int>(0);
            EzyUTClient       utClient     = (EzyUTClient)client;
            EzyUTSocketClient socket       = (EzyUTSocketClient)client.getSocket();

            if (responseCode == EzyStatusCodes.OK)
            {
                utClient.setUdpStatus(EzyConnectionStatus.CONNECTED);
                socket.udpSetStatus(EzySocketStatus.CONNECTED);
                onAuthenticated(data);
            }
            else
            {
                utClient.setUdpStatus(EzyConnectionStatus.FAILURE);
                socket.udpSetStatus(EzySocketStatus.CONNECT_FAILED);
                onAuthenticationError(data);
            }
        }
        public List <T> toList <T>(EzyArray array)
        {
            List <T> answer = new List <T>();

            for (int i = 0; i < array.size(); ++i)
            {
                object item  = array.get <object>(i);
                object sitem = item;
                if (item != null)
                {
                    EzyObjectToMap objectToMap = EzyObjectToMap.getInstance();
                    if (item is EzyObject)
                    {
                        sitem = objectToMap.toMap <object, object>((EzyObject)item);
                    }
                    else if (item is EzyArray)
                    {
                        sitem = toList <object>((EzyArray)item);
                    }
                }
                answer.Add((T)sitem);
            }
            return(answer);
        }
 public void handle(EzySocketDataEvent evt)
 {
     EzyArray data       = evt.getData();
     int      command    = data.get <int>(0);
     EzyArray parameters = data.get <EzyArray>(1);
 }
        protected virtual void onAuthenticationError(EzyArray data)
        {
            int responseCode = data.get <int>(0);

            logger.info("udp authentication error: " + responseCode);
        }
Exemple #17
0
 protected void preHandle(EzyArray data)
 {
     this.client.setSessionId(data.get <long>(2));
     this.client.setSessionToken(data.get <String>(1));
 }