Exemple #1
0
        public void write(UserToken token, byte type, int area, int command, object message)
        {
            byte[] value = MessageEncoding.encode(CreateSocketModel(type, area, command, message));
            value = LengthEncoding.encode(value);

            token.write(value);
        }
Exemple #2
0
        static byte[] createBattleRoom()
        {
            SocketModel model = new SocketModel();

            model.type    = TypeProtocol.TYPE_BATTLE_ROOM;
            model.area    = 0;
            model.command = BattleRoomProtocol.CREATE_ONE_C;
            model.message = null;
            var message = MessageEncoding.encode(model);

            return(LengthEncoding.encode(message));
        }
Exemple #3
0
 public void brocast(byte type, int area, int command, object message, UserToken exToken = null)
 {
     byte[] value = MessageEncoding.encode(CreateSocketModel(type, area, command, message));
     value = LengthEncoding.encode(value);
     foreach (UserToken item in list)
     {
         if (item != exToken)
         {
             byte[] bs = new byte[value.Length];
             Array.Copy(value, 0, bs, 0, value.Length);
             item.write(bs);
         }
     }
 }
Exemple #4
0
 public void brocast(byte type, int area, int command, ReturnDTO message, UserToken exToken = null)
 {
     byte[] value = MessageEncoding.encode(createSocketModel(type, area, command, message));
     value = LengthEncoding.encode(value);
     foreach (var item in list)
     {
         if (exToken != item)
         {
             byte[] bs = new byte[value.Length];
             Array.Copy(value, bs, value.Length);
             item.write(bs);
         }
     }
 }
Exemple #5
0
        static byte[] login()
        {
            AccountInfoDTO accountInfoDTO = new AccountInfoDTO();

            accountInfoDTO.accountName = "admin";
            accountInfoDTO.password    = "******";
            SocketModel model = new SocketModel();

            model.type    = TypeProtocol.TYPE_LOGIN;
            model.area    = 0;
            model.command = LoginProtocol.LOGIN_CREQ;
            model.message = accountInfoDTO;
            var message = MessageEncoding.encode(model);

            return(LengthEncoding.encode(message));
        }
Exemple #6
0
        private static byte[] useskill()
        {
            SocketModel model = new SocketModel();

            model.type    = TypeProtocol.TYPE_BATTLE_ROOM;
            model.area    = 0;
            model.command = BattleRoomProtocol.USE_SKILL_C;
            RoomDTO dto = new RoomDTO();

            dto.roomId     = roomDTO.roomId;
            dto.roomRoleId = roomDTO.roomRoleId;
            model.message  = dto;
            var message = MessageEncoding.encode(model);

            return(LengthEncoding.encode(message));
        }
Exemple #7
0
 public void writeToUsers(int[] users, byte type, int area, int command, object message)
 {
     byte[] value = MessageEncoding.encode(CreateSocketModel(type, area, command, message));
     value = LengthEncoding.encode(value);
     foreach (int item in users)
     {
         UserToken token = userBiz.getToken(item);
         if (token == null)
         {
             continue;
         }
         byte[] bs = new byte[value.Length];
         Array.Copy(value, 0, bs, 0, value.Length);
         token.write(bs);
     }
 }
 public void writeToUsers(long[] users, byte type, int area, int command, ReturnDTO message)
 {
     byte[] value = MessageEncoding.encode(createSocketModel(type, area, command, message));
     value = LengthEncoding.encode(value);
     foreach (var item in users)
     {
         UserToken token = getToken(item);
         if (token == null)
         {
             continue;
         }
         byte[] bs = new byte[value.Length];
         Array.Copy(value, bs, value.Length);
         token.write(bs);
     }
 }
Exemple #9
0
        private static byte[] usecard()
        {
            SocketModel model = new SocketModel();

            model.type    = TypeProtocol.TYPE_BATTLE_ROOM;
            model.area    = 0;
            model.command = BattleRoomProtocol.USE_CARD_C;
            RoomDTO dto = new RoomDTO();

            dto.roomId     = roomDTO.roomId;
            dto.roomRoleId = roomDTO.roomRoleId;
            dto.map.Add(CommonFieldProtocol.useCardId, selfInfo[0].cardIds[0]);
            dto.map.Add(CommonFieldProtocol.targetIds, new List <string> {
                otherInfo[0].roomRoleId
            });

            model.message = dto;
            var message = MessageEncoding.encode(model);

            return(LengthEncoding.encode(message));
        }
Exemple #10
0
 public void Write(UserToken token, byte type, int area, int command, object message)
 {
     byte[] send = MessageEncoding.encode(CreatSocketModel(type, area, command, message));
     send = LengthEncoding.encode(send);
     token.write(send);
 }