public static unsafe void Echo(Serializer.Message front, string message) //Used to send the given message with the given message ID to all clients minus the client with the IP of the last packet { char * oGIP = GetLastPacketIP(); //Get the IP of the packet from the original sender to prevent ghosting IntPtr careIP = (IntPtr)oGIP; StraightCharPointer *IPdata = (StraightCharPointer *)careIP; string newIP = Marshal.PtrToStringAnsi((IntPtr)IPdata->mes); for (int i = 0; i < mConnectedClients.Count; ++i) { if (mConnectedClients[i].IP != newIP) { SendData((int)front, message, message.Length, mConnectedClients[i].IP); } } }
public static unsafe void addClient() { char * ip = GetLastPacketIP(); IntPtr careTwo = (IntPtr)ip; StraightCharPointer *dataTwo = (StraightCharPointer *)careTwo; string newIP = Marshal.PtrToStringAnsi((IntPtr)dataTwo->mes); ConnectedClientInfo newClient = new ConnectedClientInfo(); newClient.IP = newIP; newClient.ID = clientID.ToString(); ++clientID; mConnectedClients.Add(newClient); string gOCount = allGOs.Length.ToString() + "|"; SendData((int)Serializer.Message.LOADLEVEL, gOCount, gOCount.Length, newIP); for (int i = 0; i < allGOs.Length; ++i) { string serializedObj = Serializer.serialize(allGOs[i]); SendData((int)Serializer.Message.GO_UPDATE, serializedObj, serializedObj.Length, newIP); } SendData((int)Serializer.Message.LEVELLOADED, gOCount, gOCount.Length, newIP); }