/// <summary> /// Initialize component, or destroy if an active instance of it already /// exists. /// </summary> void Awake() { if (net != null) { Destroy(this); return; } net = this; DontDestroyOnLoad(net); packetExecutor = GetComponent <IPacketExecutorContext>(); packetQueue = new PacketQueue(); client = new Client("localhost", port, packetQueue); }
public void HandlePackets(IPacketExecutorContext context) { IPacket packet; while (true) { lock (packets) { if (packets.Count == 0) { return; } packet = packets.First.Value; packets.RemoveFirst(); } packet.Handle(context); } }
/// <inheritdoc/> public void Handle(IPacketExecutorContext context) { // We should never recieve a handshake packet from a server. }
/// <inheritdoc/> public void Handle(IPacketExecutorContext context) { // TODO Update scene in Unity. }