Exemplo n.º 1
0
        void ClientAccepted(int id)
        {
            ClientInfoRequestPacket cirp = new ClientInfoRequestPacket(id);

            tcpServer.Send(cirp, id);
            Clients.Add(id);
        }
Exemplo n.º 2
0
 private void ProcessInputPacket(Packet packet)
 {
     if (packet is ClientInfoRequestPacket)
     {
         Trace.WriteLine("Received ClientInfoRequest");
         ClientInfoRequestPacket  cir = packet as ClientInfoRequestPacket;
         ClientInfoResponsePacket clientInfoResponse = new ClientInfoResponsePacket(sAlias);
         client.Send(clientInfoResponse);
         CallClientInfoRequestReceived(cir.ID);
     }
     else if (packet is ChatPacket)
     {
         ChatPacket cp = packet as ChatPacket;
         CallChatMessageReceived(new ChatMessage(cp.message, cp.player));
     }
     else if (packet is ObjectAddedPacket)
     {
         Trace.WriteLine("Received ObjectAdded");
         ObjectAddedPacket corp = packet as ObjectAddedPacket;
         CallObjectRequestResponseReceived(corp.Owner, corp.ID, corp.AssetName);
     }
     else if (packet is ObjectUpdatePacket)
     {
         ObjectUpdatePacket oup = packet as ObjectUpdatePacket;
         CallObjectUpdateReceived(oup.objectId, oup.assetName, oup.position, oup.orientation, oup.velocity);
     }
     else if (packet is ObjectActionPacket)
     {
         ObjectActionPacket oap = packet as ObjectActionPacket;
         CallObjectActionReceived(oap.objectId, oap.actionParameters);
     }
     else if (packet is ClientDisconnectPacket)
     {
         ClientDisconnectPacket cdp = packet as ClientDisconnectPacket;
         CallOtherClientDisconnectedFromServer(cdp.id);
     }
     else if (packet is ClientConnectedPacket)
     {
         ClientConnectedPacket ccp = packet as ClientConnectedPacket;
         CallOtherClientConnectedToServer(ccp.ID, ccp.Alias);
     }
     else if (packet is ObjectAttributePacket)
     {
         ObjectAttributePacket oap = packet as ObjectAttributePacket;
         CallObjectAttributeReceived(oap);
     }
     else if (packet is ObjectDeletedPacket)
     {
         Trace.WriteLine("Received ObjectDelete");
         ObjectDeletedPacket odp = packet as ObjectDeletedPacket;
         CallObjectDeleteReceived(odp);
     }
 }
Exemplo n.º 3
0
        void listener_ClientAccepted(Socket s)
        {
            int        id = GetAvailableClientId();
            IPEndPoint ep = null;

            if (s.RemoteEndPoint is IPEndPoint)
            {
                ep = s.RemoteEndPoint as IPEndPoint;
            }

            ClientInfo ci = new ClientInfo(id, ep, string.Empty, s);

            ci.ClientDisconnected += new Helper.Handlers.StringEH(ci_ClientDisconnected);
            ci.Start();
            ci.PacketReceived += new ClientInfo.PacketReceivedEventHandler(PacketReceived);
            Clients.Add(id, ci);
            ClientInfoRequestPacket cirp = new ClientInfoRequestPacket();

            ci.Send(cirp);
        }