void OnCommandReceived(UdpBitStream buffer) { if (ParseHeader(ref buffer)) { stats.CommandsReceived += 1; buffer.Ptr = UdpHeader.GetSize(socket); UdpCommandType cmd = (UdpCommandType)buffer.ReadByte(8); switch (cmd) { case UdpCommandType.Connect: OnCommandConnect(buffer); break; case UdpCommandType.Accepted: OnCommandAccepted(buffer); break; case UdpCommandType.Refused: OnCommandRefused(buffer); break; case UdpCommandType.Disconnected: OnCommandDisconnected(buffer); break; case UdpCommandType.Ping: OnCommandPing(buffer); break; default: ConnectionError(UdpConnectionError.IncorrectCommand); break; } } }
void RecvUnconnectedPacket(UdpBitStream buff, UdpEndPoint ep) { buff.Ptr = UdpHeader.GetSize(this); if (buff.ReadByte(8) == (byte)UdpCommandType.Connect) { if (Config.AllowIncommingConnections && ((connLookup.Count + pendingConnections.Count) < Config.ConnectionLimit || Config.ConnectionLimit == -1)) { if (Config.AutoAcceptIncommingConnections) { AcceptConnection(ep); } else { if (pendingConnections.Add(ep)) { Raise(UdpEvent.PUBLIC_CONNECT_REQUEST, ep); } } } else { SendRefusedCommand(ep); } } else { UdpLog.Debug("received invalid header byte in unconnected packet from {0}", ep.ToString()); } }
public static Color32 ReadColor32RGB(ref UdpBitStream stream) { return(new Color32(stream.ReadByte(8), stream.ReadByte(8), stream.ReadByte(8), 0xFF)); }
void OnCommandReceived(UdpBitStream buffer) { if (ParseHeader(ref buffer)) { stats.CommandsReceived += 1; buffer.Ptr = UdpHeader.GetSize(socket); UdpCommandType cmd = (UdpCommandType) buffer.ReadByte(8); switch (cmd) { case UdpCommandType.Connect: OnCommandConnect(buffer); break; case UdpCommandType.Accepted: OnCommandAccepted(buffer); break; case UdpCommandType.Refused: OnCommandRefused(buffer); break; case UdpCommandType.Disconnected: OnCommandDisconnected(buffer); break; case UdpCommandType.Ping: OnCommandPing(buffer); break; default: ConnectionError(UdpConnectionError.IncorrectCommand); break; } } }
public static Color32 ReadColor32RGBA(ref UdpBitStream stream) { return new Color32(stream.ReadByte(8), stream.ReadByte(8), stream.ReadByte(8), stream.ReadByte(8)); }