Ejemplo n.º 1
0
        public override void Close(string msg = null)
        {
            if (!isActive)
            {
                return;
            }

            SteamManager.LeaveLobby();

            isActive = false;

            IWriteMessage outMsg = new WriteOnlyMessage();

            outMsg.Write((byte)DeliveryMethod.Reliable);
            outMsg.Write((byte)PacketHeader.IsDisconnectMessage);
            outMsg.Write(msg ?? "Disconnected");

            Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Reliable);
            sentBytes += outMsg.LengthBytes;

            Thread.Sleep(100);

            Steamworks.SteamNetworking.ResetActions();

            Steamworks.SteamNetworking.CloseP2PSessionWithUser(hostSteamId);

            steamAuthTicket?.Cancel(); steamAuthTicket = null;
            hostSteamId = 0;

            OnDisconnect?.Invoke();
        }
Ejemplo n.º 2
0
        public override void Close(string msg = null)
        {
            if (!isActive)
            {
                return;
            }

            isActive = false;

            netClient.Shutdown(msg ?? TextManager.Get("Disconnecting"));
            netClient = null;
            steamAuthTicket?.Cancel(); steamAuthTicket = null;
            OnDisconnect?.Invoke();
        }