void PacketReceived(int id, Packet p) { if (!Clients.Contains(id)) { return; } ClientPacketInfo cpi = new ClientPacketInfo(id, p); InputQueue.Enqueue(cpi); }
private void ProcessInputPacket(ClientPacketInfo cpi) { if (cpi == null) { return; } Packet packet = cpi.packet; if (packet is ClientInfoResponsePacket) { Trace.WriteLine("Received Client info Response"); //client connects. Server sends infoRequest, Client sends infoResponse. ClientInfoResponsePacket cirp = packet as ClientInfoResponsePacket; CallClientConnected(cpi.id, cirp.Alias); // Let everyone know they joined ClientConnectedPacket ccp = new ClientConnectedPacket(cpi.id, cirp.Alias); BroadcastPacket(ccp); } else if (packet is ClientReadyPacket) { ClientReadyPacket crp = packet as ClientReadyPacket; CallClientReadyReceived(crp.Id, crp.Alias); } else if (packet is ChatPacket) { ChatPacket cp = packet as ChatPacket; BroadcastChatMessage(cp.message, cp.player); CallChatMessageReceived(new ChatMessage(cp.message, cp.player)); } else if (packet is ObjectRequestPacket) { Trace.WriteLine("Received ObjectRequestPacket"); ObjectRequestPacket corp = packet as ObjectRequestPacket; CallObjectRequestReceived(cpi.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 ObjectAttributePacket) { ObjectAttributePacket oap = packet as ObjectAttributePacket; CallObjectAttributeReceived(oap); } }
private void ProcessInputPacket(ClientPacketInfo cpi) { if (cpi == null) return; Packet packet = cpi.packet; if (packet is ClientInfoResponsePacket) { Trace.WriteLine("Received Client info Response"); //client connects. Server sends infoRequest, Client sends infoResponse. ClientInfoResponsePacket cirp = packet as ClientInfoResponsePacket; CallClientConnected(cpi.id, cirp.Alias); // Let everyone know they joined ClientConnectedPacket ccp = new ClientConnectedPacket(cpi.id, cirp.Alias); BroadcastPacket(ccp); } else if(packet is ClientReadyPacket) { ClientReadyPacket crp = packet as ClientReadyPacket; CallClientReadyReceived(crp.Id, crp.Alias); } else if (packet is ChatPacket) { ChatPacket cp = packet as ChatPacket; BroadcastChatMessage(cp.message, cp.player); CallChatMessageReceived(new ChatMessage(cp.message, cp.player)); } else if (packet is ObjectRequestPacket) { Trace.WriteLine("Received ObjectRequestPacket"); ObjectRequestPacket corp = packet as ObjectRequestPacket; CallObjectRequestReceived(cpi.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 ObjectAttributePacket) { ObjectAttributePacket oap = packet as ObjectAttributePacket; CallObjectAttributeReceived(oap); } }
void PacketReceived(int id, Packet p) { if (!Clients.Contains(id)) return; ClientPacketInfo cpi = new ClientPacketInfo(id, p); InputQueue.Enqueue(cpi); }
private void ProcessInputPacket(ClientPacketInfo cpi) { if (cpi == null) return; Packet packet = cpi.packet; if (packet is ClientInfoResponsePacket) { ClientInfoResponsePacket cirp = packet as ClientInfoResponsePacket; cpi.client.alias = cirp.Alias; CallClientConnected(cpi.client.alias); } else if (packet is ChatPacket) { ChatPacket cp = packet as ChatPacket; SendChatPacket(cp.message, cp.player); CallChatMessageReceived(cp.message, cp.player); } else if (packet is ObjectRequestPacket) { ObjectRequestPacket corp = packet as ObjectRequestPacket; CallObjectRequestReceived(cpi.client.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); } }
void PacketReceived(int id, Packet p) { if (!Clients.ContainsKey(id)) return; ClientInfo ci = Clients[id]; ClientPacketInfo cpi = new ClientPacketInfo(ref ci, p); InputQueue.Enqueue(cpi); }