Пример #1
0
 protected void printSentData(EzyCommand cmd, EzyArray data)
 {
     if (!unloggableCommands.Contains(cmd))
     {
         logger.debug("send command: " + cmd + " and data: " + data);
     }
 }
Пример #2
0
        public EzySimpleResponse(EzyArray data)
        {
            this.data = data;
            int cmdId = data.get <int>(0);

            this.command   = (EzyCommand)cmdId;
            this.timestamp = DateTime.Now;
        }
        public virtual EzyArray serialize(EzyCommand cmd, EzyArray data)
        {
            EzyArray array = EzyEntityFactory.newArrayBuilder()
                             .append((int)cmd)
                             .append(data)
                             .build();

            return(array);
        }
Пример #4
0
        public void send(EzyCommand cmd, EzyArray data)
        {
            EzyArray array = requestSerializer.serialize(cmd, data);

            if (socketClient != null)
            {
                socketClient.sendMessage(array);
                printSentData(cmd, data);
            }
        }
Пример #5
0
        public override void udpSend(EzyCommand cmd, EzyArray data)
        {
            EzyArray array = requestSerializer.serialize(cmd, data);

            if (socketClient != null)
            {
                ((EzyUTSocketClient)socketClient).udpSendMessage(array);
                printSentData(cmd, data);
            }
        }
 public void handle(EzyCommand cmd, EzyArray data)
 {
     if (handlers.ContainsKey(cmd))
     {
         EzyDataHandler hd = handlers[cmd];
         hd.handle(data);
     }
     else
     {
         logger.warn("has no handler for command: " + cmd);
     }
 }
        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);
            }
        }
Пример #8
0
 public virtual void udpSend(EzyCommand cmd, EzyArray data)
 {
     throw new InvalidOperationException("only support TCP, use EzyUTClient instead");
 }