public void Send(SocketMsg msg)
    {
        byte[] data   = EncoderTool.EncodeMsg(msg);
        byte[] packet = EncoderTool.EnconderPacket(data);

        try
        {
            socket.Send(packet);
        }
        catch (System.Exception e)
        {
            Debug.LogError(e.Message);
        }
    }
Exemple #2
0
        /// <summary>
        /// 广播房间内的玩家这条消息
        /// </summary>
        /// <param name="opCode"></param>
        /// <param name="subCode"></param>
        /// <param name="value"></param>
        public void Brocast(int opCode, int subCode, object value, ClientPeer exClient = null)
        {
            SocketMsg msg = new SocketMsg(opCode, subCode, value);

            byte[] data   = EncoderTool.EncodeMsg(msg);
            byte[] packet = EncoderTool.EnconderPacket(data);

            foreach (var client in uIdClientDict.Values)
            {
                if (client == exClient)
                {
                    continue;
                }

                client.Send(packet);
            }
        }
Exemple #3
0
        /// <summary>
        /// 广播
        /// </summary>
        private void Brocast(FightRoom room, int opCode, int subCode, object value, ClientPeer exClient = null)
        {
            SocketMsg msg = new SocketMsg(opCode, subCode, value);

            byte[] data   = EncoderTool.EncodeMsg(msg);
            byte[] packet = EncoderTool.EnconderPacket(data);

            foreach (PlayerDto player in room.PlayerList)
            {
                if (user.IsOnLine(player.id))  //425
                {
                    ClientPeer client = user.GetClientById(player.id);
                    if (client == exClient)
                    {
                        continue;
                    }
                    client.Send(packet);
                }
            }
        }