void RecvUnconnectedPacket(UdpStream buffer, UdpEndPoint ep) { UdpAssert.Assert(buffer.Ptr == 0); buffer.Ptr = HeaderBitSize; if (buffer.ReadByte(8) == (byte)UdpCommandType.Connect) { if (Config.AllowIncommingConnections && ((connLookup.Count + pendingConnections.Count) < Config.ConnectionLimit || Config.ConnectionLimit == -1)) { if (Config.AutoAcceptIncommingConnections) { AcceptConnection(ep, null); } else { if (pendingConnections.Add(ep)) { object obj = null; if (buffer.ReadByte(8) == UdpEvent.INTERNAL_COMMAND_HASOBJECT) { //they've also sent an object along with their connection request serializer.Unpack(buffer, ref obj); } Raise(UdpEvent.PUBLIC_CONNECT_REQUEST, ep, obj); } } } else { SendRefusedCommand(ep); } } }
void OnObjectReceived(UdpStream buffer) { EnsureClientIsConnected(); if (CheckState(UdpConnectionState.Connected) == false) { return; } if (ParseHeader(buffer)) { object obj = null; buffer.Ptr = UdpSocket.HeaderBitSize; if (serializer.Unpack(buffer, ref obj)) { socket.Raise(UdpEvent.PUBLIC_OBJECT_RECEIVED, this, obj); } } }