public bool Send <T>(int sessionID, PACKET_ID packetID, T data)
        {
            var bodyData = CGSFNETCommon.JsonEnDecode.Encode <T>(data);
            var result   = SendPacket(sessionID, (ushort)packetID, bodyData);

            return(result);
        }
        //네트워크 Read/Send 스레드 부분
        public void PostSendPacket(PACKET_ID packetID, byte[] bodyData)
        {
            if (Network.IsConnected() == false)
            {
                Debug.LogWarning("서버에 접속하지 않았습니다");
                return;
            }

            List <byte> dataSource = new List <byte>();
            var         packetSize = 0;

            if (bodyData != null)
            {
                packetSize = (Int16)(bodyData.Length + PacketHeaderSize);
            }
            else
            {
                packetSize = (Int16)(PacketHeaderSize);
            }

            dataSource.AddRange(BitConverter.GetBytes((Int16)packetSize));
            dataSource.AddRange(BitConverter.GetBytes((Int16)packetID));
            dataSource.AddRange(new byte[] { (byte)0 });
            if (bodyData != null)
            {
                dataSource.AddRange(bodyData);
            }
            SendPacketQueue.Enqueue(dataSource.ToArray());
        }
        public void PostSendPacket(PACKET_ID packetID, byte[] bodyData)
        {
            if (TcpNetLobbyServer.IsConnected == false)
            {
                DevLog.Write("서버 연결이 되어 있지 않습니다", LOG_LEVEL.ERROR);
                return;
            }

            Int16 bodyDataSize = 0;

            if (bodyData != null)
            {
                bodyDataSize = (Int16)bodyData.Length;
            }
            var packetSize = bodyDataSize + ClientNetLib.PacketDef.PACKET_HEADER_SIZE;

            List <byte> dataSource = new List <byte>();

            dataSource.AddRange(BitConverter.GetBytes((UInt16)packetSize));
            dataSource.AddRange(BitConverter.GetBytes((UInt16)packetID));
            dataSource.AddRange(new byte[] { (byte)0 });

            if (bodyData != null)
            {
                dataSource.AddRange(bodyData);
            }

            TcpNetLobbyServer.Send(dataSource.ToArray());
        }
Пример #4
0
        public void PostSendPacket(PACKET_ID packetID, byte[] bodyData)
        {
            if (NetWork.IsConnected() == false)
            {
                return;
            }

            Int16 bodyDataSize = 0;

            if (bodyData != null)
            {
                bodyDataSize = (Int16)bodyData.Length;
            }

            var PacketSize = bodyDataSize + PacketDef.PACKET_HEADER_SIZE;

            List <byte> dataSource = new List <byte>();

            dataSource.AddRange(BitConverter.GetBytes((Int16)PacketSize));
            dataSource.AddRange(BitConverter.GetBytes((Int16)packetID));
            dataSource.AddRange(new byte[] { (byte)0 });

            if (bodyData != null)
            {
                dataSource.AddRange(bodyData);
            }
            SendPacketQueue.Enqueue(dataSource.ToArray());
        }
Пример #5
0
    public void PostSendPacket(PACKET_ID packetID, byte[] bodyData)
    {
        if (m_transport.IsConnected == false)
        {
            return;
        }

        Int16 bodyDataSize = 0;

        if (bodyData != null)
        {
            bodyDataSize = (Int16)bodyData.Length;
        }
        var packetSize = bodyDataSize + NetLib.PacketDef.PACKET_HEADER_SIZE;

        List <byte> dataSource = new List <byte>();

        dataSource.AddRange(BitConverter.GetBytes((UInt16)packetSize));
        dataSource.AddRange(BitConverter.GetBytes((UInt16)packetID));
        dataSource.AddRange(new byte[] { (byte)0 });

        if (bodyData != null)
        {
            dataSource.AddRange(bodyData);
        }

        m_transport.Send(dataSource.ToArray());
    }
Пример #6
0
        void PostSendPacket(PACKET_ID packetID, byte[] bodyData)
        {
            if (Network.IsConnected() == false)
            {
                MessageBox.Show("서버에 접속하지 않았습니다");
                return;
            }

            List <byte> dataSource = new List <byte>();

            if (bodyData != null)
            {
                var packetSize = (Int16)(bodyData.Length + PacketHeaderSize);
                dataSource.AddRange(BitConverter.GetBytes(packetSize));
                dataSource.AddRange(BitConverter.GetBytes((Int16)packetID));
                dataSource.AddRange(bodyData);
            }
            else
            {
                var packetSize = (Int16)(PacketHeaderSize);
                dataSource.AddRange(BitConverter.GetBytes(packetSize));
                dataSource.AddRange(BitConverter.GetBytes((Int16)packetID));
            }

            SendPacketQueue.Enqueue(dataSource.ToArray());
        }
Пример #7
0
        public void PostSendPacket(PACKET_ID packetID, byte[] bodyData)
        {
            if (false == Socket.IsConnected())
            {
                Log.Write("Not connected to server", LOG_LEVEL.ERROR);
                return;
            }

            Int16 bodyDataSize = bodyData == null ? (Int16)0 : (Int16)bodyData.Length;

            // Total packet size is "Header + packet body"
            var packetSize = bodyDataSize + PacketDef.PACKET_HEADER_SIZE;

            // Packet header of our protocol as follows
            // First 2 bytes : total packet size
            // Second 2 bytes : packet Id
            // last 1 byte : packet type
            List <byte> dataSource = new List <byte>();

            dataSource.AddRange(BitConverter.GetBytes((Int16)packetSize));
            dataSource.AddRange(BitConverter.GetBytes((Int16)packetID));
            dataSource.AddRange(new byte[] { (byte)0 });

            if (bodyData != null)
            {
                dataSource.AddRange(bodyData);
            }

            SendPacketQueue.Enqueue(dataSource.ToArray());
        }
        //네트워크 Read/Send 스레드 부분
        void PostSendPacket(PACKET_ID packetID, byte[] bodyData)
        {
            var packetHeaderSize = ClientNetLib.PacketDef.PACKET_HEADER_SIZE;

            if (Network.IsConnected == false)
            {
                Debug.LogWarning("서버에 접속하지 않았습니다");
                return;
            }

            List <byte> dataSource = new List <byte>();
            UInt16      packetSize = 0;

            if (bodyData != null)
            {
                packetSize = (UInt16)(bodyData.Length + packetHeaderSize);
            }
            else
            {
                packetSize = (UInt16)(packetHeaderSize);
            }

            dataSource.AddRange(BitConverter.GetBytes(packetSize));
            dataSource.AddRange(BitConverter.GetBytes((UInt16)packetID));
            dataSource.AddRange(new byte[] { (byte)0 });
            if (bodyData != null)
            {
                dataSource.AddRange(bodyData);
            }

            Network.Send(dataSource.ToArray());
        }
        public void InsertDBRequest(PACKET_ID packetID, int sessionID, string userID, byte[] jobDatas)
        {
            var request = new DB.RequestData()
            {
                PacketID  = packetID,
                SessionID = sessionID,
                UserID    = userID,
                Datas     = jobDatas
            };

            DBManagerRef.InsertRequest(request);
        }
Пример #10
0
        public void PostSendPacket(PACKET_ID packetID, byte[] packetData)
        {
            if (Network.IsConnected() == false)
            {
                DevLog.Write("서버 연결이 되어 있지 않습니다", LOG_LEVEL.ERROR);
                return;
            }

            var header = new MsgPackPacketHeadInfo();

            header.TotalSize = (UInt16)packetData.Length;
            header.Id        = (UInt16)packetID;
            header.Type      = 0;
            header.Write(packetData);

            SendPacketQueue.Enqueue(packetData);
        }
Пример #11
0
        public void PostSendPacket(PACKET_ID packetID, RoomChatReqPacket packet)
        {
            if (Network.IsConnected() == false)
            {
                Console.WriteLine("서버 연결이 되어 있지 않습니다.");
                return;
            }
            //Int16 BodyDataSize = (Int16)bodyData.Length;
            //var PacketSize = (Int16)bodyData.Length;//BodyDataSize + PacketDef.PACKET_HEADER_SIZE;
            var PacketSize = packet.GetMsgLen() + PacketDef.PACKET_HEADER_SIZE;
            var BodyData   = packet.GetMsg();

            List <byte> dataSource = new List <byte>();

            dataSource.AddRange(BitConverter.GetBytes((Int16)PacketSize));
            dataSource.AddRange(BitConverter.GetBytes((Int16)packetID));
            dataSource.AddRange(BodyData);
            SendPacketQueue.Enqueue(dataSource.ToArray());
        }