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

Was this helpful?

  1. SDK
  2. Network Client
  3. Classes

NetworkClient Class

Namespace: SWNetwork

NetworkClient is the entry point of your game to interact with the SocketWeaver backend services. You must have one and only one NetworkClient active in your Scene.

It is recommended to add the NetworkClient component to a separate GameObject in your scene. NetworkClient will automatically prevent the GameObject from being destroyed between Scenes.

Declaration

public class NetworkClient : MonoBehaviour

Properties

Type

Description

VERSION

string

SWNetwork SDK version.

Lobby

Lobby instance.

IsHost

bool

Indicates whether the local player is the host of a game.

IsHost gets set when clients connect to the room game server and is managed by the game server, the game server is always polling all connected clients. If the current host player got disconnected, the game server will select a new host.

PlayerId

string

Local player's Id.

LastSpawner

SceneSpawner

Last SceneSpawner. Usually, it is the SceneSpawner of the last loaded scene.

loggingLevel

LoggingLevel

Controls the logging of the SWNetwork SDK lower level code.

Error is the default setting.

Log File Path

string

Controls log output directory

Development Player Id

string

Overrides the playerId for development use.

On the first launch of a SocketWeaver powered networked game, SWNetwork SDK generates a unique playerId and stores it in the player's device hard drive. This playerId is used in the SocketWeaver backends to identify the player.

For development and testing use, you can manually assign a playerId using this field.

API_KEY

string

The APIKEY of your game. It is generated in the SocketWeaver Developer Portal

lobbyName

string

Preferred Lobby region name.

nodeRegion1

string

Preferred game server region name1.

nodeRegion2

string

Preferred game server region name2.

LobbyPing

int

Network latency between the client and the lobby server in milliseconds (ms).

GameServerPing

int

Network latency between the client and the game server in milliseconds (ms).

Methods

Description

DisconnectFromRoom()

Disconnects the local player from the room game servers.

ConnectToRoom(Action<bool>)

Connects the local player to the room game servers.

FindSpawner(UInt16)

Finds the SceneSpawner with the specified SpawnerId.

CheckIn()

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

CheckIn(string)

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

PreviousClassesNextMethods

Last updated 5 years ago

Was this helpful?

SWLobby