private void ProcessInputPacket(Packet packet) { if (packet is ClientInfoRequestPacket) { ClientInfoResponsePacket clientInfoResponse = new ClientInfoResponsePacket(sAlias); client.Send(clientInfoResponse); } else if (packet is ChatPacket) { ChatPacket cp = packet as ChatPacket; CallChatMessageReceived(cp.message, cp.player); } else if (packet is ObjectResponsePacket) { ObjectResponsePacket corp = packet as ObjectResponsePacket; CallObjectRequestResponseReceived(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; CallClientDisconnected(cdp.Alias); } }
private void ProcessInputPacket(Packet packet) { if (packet is ClientInfoRequestPacket) { Debug.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) { Debug.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; CallPlayerDisconnected(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) { Debug.WriteLine("Received ObjectDelete"); ObjectDeletedPacket odp = packet as ObjectDeletedPacket; CallObjectDeleteReceived(odp); } }