NetworkConnectionToClient.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. namespace Mirror
  3. {
  4. public class NetworkConnectionToClient : NetworkConnection
  5. {
  6. public override string address =>
  7. Transport.activeTransport.ServerGetClientAddress(connectionId);
  8. // unbatcher
  9. public Unbatcher unbatcher = new Unbatcher();
  10. public NetworkConnectionToClient(int networkConnectionId)
  11. : base(networkConnectionId) {}
  12. // Send stage three: hand off to transport
  13. protected override void SendToTransport(ArraySegment<byte> segment, int channelId = Channels.Reliable) =>
  14. Transport.activeTransport.ServerSend(connectionId, segment, channelId);
  15. /// <summary>Disconnects this connection.</summary>
  16. public override void Disconnect()
  17. {
  18. // set not ready and handle clientscene disconnect in any case
  19. // (might be client or host mode here)
  20. isReady = false;
  21. Transport.activeTransport.ServerDisconnect(connectionId);
  22. // IMPORTANT: NetworkConnection.Disconnect() is NOT called for
  23. // voluntary disconnects from the other end.
  24. // -> so all 'on disconnect' cleanup code needs to be in
  25. // OnTransportDisconnect, where it's called for both voluntary
  26. // and involuntary disconnects!
  27. }
  28. }
  29. }