LogoLogo
  • SWNetwork SDK Overview
  • Installation
    • Custom Unity Package
  • Tutorials
    • Third-Person Shooter
      • Starter Project Introduction
      • Install SWNetwork
      • Setting up the NetworkClient
      • Sync Player Transform
      • Setting up the Scene Spawner
      • Test and Play
      • Remote Events
      • SyncProperties
      • Player Respawn
      • Updating Room States
      • Winning the Game
    • Basic Lobby
      • Lobby-start
      • Installing SWNetwork SDK and configuring NetworkClient
      • Registering Player
      • Room CRUD
      • Managing Teams
      • Chat
  • SDK
    • Network Client
      • Check-in
      • Game Servers
      • Network Status Event (beta)
      • Classes
        • NetworkClient Class
      • Methods
        • CheckIn() Method
        • ConnectToRoom(Action<bool>) Method
        • DisconnectFromRoom () Method
        • FindSpawner(ushort) Method
    • Game Play
      • Network ID
      • Realtime Agent
      • Remote Event
      • Sync Property
        • Restore Sync Properties
        • Conflict Resolution
      • SceneSpawner
      • RoomPropertyAgent
      • RoomRemoteEventAgent
    • Lobby
      • Register Player
      • Message Player
      • Create Room
      • Change Room Settings
      • Get Rooms
      • Filter Rooms
      • Join Room
      • Message Room
      • Get Players in Room
      • Get Room Custom Data
      • Change Room Custom Data
      • Kick Players
      • Start Room
      • Leave Room
      • Lobby Room Events
        • OnLobbyConnectedEvent
        • OnPlayerMessageEvent
        • OnRoomCustomDataChangeEvent
        • OnNewPlayerJoinRoomEvent
        • OnPlayerLeaveRoomEvent
        • OnNewRoomOwnerEvent
        • OnRoomStartingEvent
        • OnRoomReadyEvent
        • OnFailedToStartRoomEvent
        • OnKickedEvent
        • OnRoomMessageEvent
      • Classes
        • SWLobby Class
        • SWPlayer Class
        • SWRoom Class
        • SWRegisterReply Class
        • SWGetRoomReply Class
        • SWJoinRoomReply Class
        • SWGetRoomCustomDataReply Class
        • SWGetPlayersReply Class
        • SWLobbyIndexData Class
        • SWLobbyFilterData Class
        • SWGetRoomFilterReply Class
        • SWLobbyError Class
        • SWMessagePlayerEventData Class
        • SWMessageRoomEventData Class
        • SWRoomCustomDataChangeEventData Class
        • SWJoinRoomEventData Class
        • SWLeaveRoomEventData Class
        • SWRoomChangeOwnerEventData Class
        • SWStartRoomEventData Class
        • SWRoomReadyEventData Class
        • SWFailedToStartRoomEventData Class
      • Methods
        • Register(Action<bool, SWRegisterReply, SWLobbyError>) Method
        • MessagePlayer(string, string, Action<bool, SWLobbyError>) Method
        • CreateRoom(bool, int, Action<bool, string, SWLobbyError>) Method
        • ChangeRoomSettings(int, int, Action<bool, SWLobbyError>) Method
        • GetRooms(int, int, Action<bool, SWGetRoomReply, SWLobbyError>) Method
        • FilterRoom(SWLobbyFilterData, byte, Action<bool, SWGetRoomFilterReply, SWLobbyError>) Method
        • JoinRoom(string, Action<bool, SWJoinRoomReply, SWLobbyError>) Method
        • JoinRoomRandomly(Action<bool, SWJoinRoomReply, SWLobbyError>) Method
        • JoinOrCreateRoom(bool, int, int, Action<bool, SWJoinRoomReply, SWLobbyError>) Method
        • MessageRoom(string, Action<bool, SWLobbyError>) Method
        • GetRoomCustomData(Action<bool, SWGetRoomCustomDataReply, SWLobbyError>) Method
        • GetPlayersInRoom(Action<bool, SWGetPlayersReply, SWLobbyError>) Method
        • ChangeRoomCustomData(string, Action<bool, SWLobbyError>) Method
        • StartRoom(Action<bool, SWLobbyError>) Method
        • LeaveRoom(Action<bool, SWLobbyError>) Method
  • Open Source Software Used
    • Credits
Powered by GitBook
On this page
  • Overview
  • Example

Was this helpful?

  1. SDK
  2. Network Client

Check-in

PreviousNetwork ClientNextGame Servers

Last updated 5 years ago

Was this helpful?

Overview

SocketWeaver needs to validate a client's API_KEY before the client can use SocketWeaver services.

You can use the CheckIn() method of the NetworkClient class to submit Clients API_KEY to SocketWeaver. The CheckIn() method also submits a client's PlayerId to SocketWeaver. The PlayerId is used in the Lobby servers and game servers to identify a player.

SWNetwork SDK randomly generates a unique PlayerId on the first launch of a game and stores the PlayerId on the device hard drive. NetworkClient loads the PlayerId from the hard drive in the Awake() method.

Using generated PlayerId

If you call CheckIn() without a custom PlayerId, NetworkClient uses the randomly generated unique PlayerId to check into the SocketWeaver services.

Custom PlayerId

You can use custom player Id to override the generated playerId by calling CheckIn(customPlayerId). This is useful if you use service like Google Firebase to manage user profiles. You can use it for development testing as well.

Connect to Lobby Servers

After validating clients' API_KEY, SocketWeaver routes clients to a lobby cluster that are geographically closest to them. SWNetwork SDK will automatically connect to the assigned lobby clusters.

You can add a handler for the and start the matchmaking process of your game from there.

Methods

CheckIn()

Checking into the SocketWeaver services with a random generated unique player Id.

CheckIn(string)

Checking into the SocketWeaver services with the specified playerId. Make sure the playerId is unique.

CheckOut()

Checking out of the SocketWeaver services. Disconnects from the room game servers and leaves the lobby room. All gameplay API and lobby API will stop working.

Example

string customPlayerId = "a1b2c3d4";
NetworkClient.Instance.CheckIn(customPlayerId, (bool successful, string error) =>
{
    if (!successful)
    {
        Debug.LogError(error);
    }

});
NetworkClient.Instance.CheckOut((bool successful, string error) =>
{
    if (!successful)
    {
        Debug.LogError(error);
    }

});
NetworkClient.Lobby.OnLobbyConncetedEvent