コード例 #1
0
 public static void write(UserToken token, SocketModel model)
 {
     //Console.WriteLine("有消息发出");
     byte[] bs = MessageEncoding.Encode(model);
     bs = LengthEncoding.encode(bs);
     token.write(bs);
 }
コード例 #2
0
 public void write(UserToken token, int type, int area, int command, object message)
 {
     byte[] bs = MessageEncoding.Encode(createSocketModel(type, area, command, message));
     bs = LengthEncoding.encode(bs);
     Console.WriteLine("有消息发出");
     token.write(bs);
 }
コード例 #3
0
        internal void Brocast(int type, int area, int command, object msg, UserToken exclude)
        {
            MSGModel message = MSGModel.CreateMessage(type, area, command, msg);

            byte[] tmp    = MessageEncoding.Encode(message);
            byte[] buffer = LengthEncoding.encode(tmp);
            foreach (RoomPlayer rp in teamOne)
            {
                if (rp.Token != exclude)
                {
                    tmp = new byte[buffer.Length];
                    Buffer.BlockCopy(buffer, 0, tmp, 0, buffer.Length);
                    rp.Token.Write(tmp);
                }
            }


            foreach (RoomPlayer rp in teamTwo)
            {
                if (rp.Token != exclude)
                {
                    tmp = new byte[buffer.Length];
                    Buffer.BlockCopy(buffer, 0, tmp, 0, buffer.Length);
                    rp.Token.Write(tmp);
                }
            }
        }
コード例 #4
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);
        }
コード例 #5
0
 public void write(UserToken token, int type, int area, int command, object message)
 {
     byte[] bs = MessageEncoding.Encode(createSocketModel(type, area, command, message));
     bs = LengthEncoding.encode(bs);
     LoggerHelper.Info(token.connectSocket.RemoteEndPoint.ToString() + "  --返回处理结果");
     token.write(bs);
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: xuxueyang/godGameServer
        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));
        }
コード例 #7
0
        public void write(int id, int type, int area, int command, object message)
        {
            UserToken token = userBiz.getToken(id);

            if (token == null)
            {
                return;
            }
            Console.WriteLine("有消息发出");
            byte[] bs = MessageEncoding.Encode(createSocketModel(type, area, command, message));
            bs = LengthEncoding.encode(bs);
            token.write(bs);
        }
コード例 #8
0
 public void brocast(int type, int area, int command, object message)
 {
     byte[] bs = MessageEncoding.Encode(createSocketModel(type, area, command, message));
     bs = LengthEncoding.encode(bs);
     //    Console.WriteLine("有群发");
     //遍历当前模块所有用户 进行消息发送
     foreach (UserToken item in list)
     {
         byte[] truebs = new byte[bs.Length];
         Array.Copy(bs, 0, truebs, 0, bs.Length);
         item.write(truebs);
     }
 }
コード例 #9
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);
         }
     }
 }
コード例 #10
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);
         }
     }
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: xuxueyang/godGameServer
        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));
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: xuxueyang/godGameServer
        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));
        }
コード例 #13
0
ファイル: AbsOnceHandler.cs プロジェクト: SunGuangdong/LOL-
 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);
     }
 }
コード例 #14
0
 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);
     }
 }
コード例 #15
0
 public void writeToUsers(int[] users, int type, int area, int command, object message)
 {
     byte[] bs = MessageEncoding.Encode(createSocketModel(type, area, command, message));
     bs = LengthEncoding.encode(bs);
     foreach (int item in users)
     {
         UserToken token = userBiz.getToken(item);
         if (token != null)
         {
             Console.WriteLine("群发给指定ID");
             byte[] truebs = new byte[bs.Length];
             Array.Copy(bs, 0, truebs, 0, bs.Length);
             token.write(truebs);
         }
     }
 }
コード例 #16
0
 public void exBrocast(UserToken token, int command, object message)
 {
     byte[] bs = MessageEncoding.Encode(createSocketModel(getType(), getArea(), command, message));
     bs = LengthEncoding.encode(bs);
     Console.WriteLine("有排除模式群发");
     //遍历当前模块所有用户 进行消息发送
     foreach (UserToken item in list)
     {
         if (item.Equals(token))
         {
             continue;
         }
         byte[] truebs = new byte[bs.Length];
         Array.Copy(bs, 0, truebs, 0, bs.Length);
         item.write(truebs);
     }
 }
コード例 #17
0
ファイル: Program.cs プロジェクト: xuxueyang/godGameServer
        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));
        }
コード例 #18
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);
 }
コード例 #19
0
 protected void write(UserToken token, int type, int area, int command, object message)
 {
     byte[] buffer = MessageEncoding.Encode(MSGModel.CreateMessage(type, area, command, message));
     buffer = LengthEncoding.encode(buffer);
     token.Write(buffer);
 }