public static void S_ChatHandler(PacketSession session, IMessage packet)
    {
        S_Chat        chatPacket    = packet as S_Chat;
        ServerSession serverSession = session as ServerSession;

        Debug.Log(chatPacket.Context);
    }
示例#2
0
    public static void S_ChatHandler(PacketSession session, IPacket packet)
    {
        S_Chat        chatPacket    = packet as S_Chat;
        ServerSession serverSession = session as ServerSession;

        //Console.WriteLine(chatPacket.chat);
    }
示例#3
0
    public static void S_ChatHandler(PacketSession session, IPacket packet)
    {
        S_Chat        chatPacket    = packet as S_Chat;
        ServerSession serverSession = session as ServerSession;

        Debug.Log($"S_Chat : playerId={chatPacket.playerId} / chat={chatPacket.chat}");
    }
    public static void S_ChatHandler(PacketSession session, IPacket packet)
    {
        S_Chat        chatPacket    = packet as S_Chat;
        ServerSession serverSession = session as ServerSession;

        // if (chatPacket.playerId == 1)
        // System.Console.WriteLine(chatPacket.chat);
    }
示例#5
0
        public void Broadcast(ClientSession session, string chat)
        {
            S_Chat packet = new S_Chat();

            packet.playerId = session.SessionId;
            packet.chat     = $"{chat} I am {packet.playerId}";
            ArraySegment <byte> segment = packet.Write();

            _pendingList.Add(segment);
        }
示例#6
0
        // * 수정된 부분
        // 이제 Broadcast는 패킷을 전송하지 않고, 전송할 패킷을 조립해서 리스트에 넣어두는 역할만 한다.
        public void Broadcast(ClientSession session, string chat)
        {
            S_Chat packet = new S_Chat();

            packet.playerId = session.SessionId;
            packet.chat     = $"[Player {packet.playerId}] : {chat}";
            ArraySegment <byte> segment = packet.Serialize();

            // 바로 전송하는 대신 리스트에 패킷을 넣는다.
            //foreach (ClientSession s in _sessions)
            //	s.Send(segment);
            _pendingList.Add(segment);
        }
        public void Broadcast(ClientSession session, string chat)
        {
            S_Chat packet = new S_Chat();

            packet.playerId = session.SessionId;
            packet.chat     = $"[Player {packet.playerId}] : {chat}";
            ArraySegment <byte> segment = packet.Serialize();

            foreach (ClientSession s in _sessions)
            {
                s.Send(segment);
            }
        }
示例#8
0
    public static void S_ChatHandler(PacketSession packetSession, IPacket packet)
    {
        S_Chat        chatPacket    = packet as S_Chat;
        ServerSession serverSession = packetSession as ServerSession;

        //if(chatPacket.playerId == 1)
        {
            Debug.Log(chatPacket.chat);

            // 유니티 관련 동작은 유니티 메인 스레드에서 실행해야 한다.
            // 백그라운드 스레드에서 호출 시 실행되지 않는다.
            GameObject go = GameObject.Find("Player");
            if (go == null)
            {
                Debug.Log("Player not found.");
            }
            else
            {
                Debug.Log("Player found!");
            }
        }
    }