/// <summary> /// Called on server from OnServerAuthenticateInternal when a client needs to authenticate /// </summary> /// <param name="conn">Connection to client.</param> public virtual void OnServerAuthenticate(NetworkConnectionToClient conn) { OnServerAuthenticated?.Invoke(conn); }
// InvokeCmd/Rpc/SyncEventDelegate can all use the same function here internal bool InvokeHandlerDelegate(int cmdHash, MirrorInvokeType invokeType, NetworkReader reader, NetworkConnectionToClient senderConnection = null) { if (GetInvokerForHash(cmdHash, invokeType, out Invoker invoker) && invoker.invokeClass.IsInstanceOfType(this)) { currentSender = senderConnection; invoker.invokeFunction(this, reader, senderConnection); currentSender = null; return(true); } return(false); }
// This will get more code in the near future internal void OnServerAuthenticateInternal(NetworkConnectionToClient conn) { OnServerAuthenticate(conn); }
protected void ServerAccept(NetworkConnectionToClient conn) { OnServerAuthenticated.Invoke(conn); }
protected void ServerReject(NetworkConnectionToClient conn) { conn.Disconnect(); }
/// <summary>Called on server from OnServerAuthenticateInternal when a client needs to authenticate</summary> public virtual void OnServerAuthenticate(NetworkConnectionToClient conn) { }
public override bool OnCheckObserver(NetworkIdentity identity, NetworkConnectionToClient newObserver) { return(identity.gameObject.scene == newObserver.identity.gameObject.scene); }
/// <summary> /// This removes an external connection added with AddExternalConnection(). /// </summary> /// <param name="connectionId">The id of the connection to remove.</param> /// <returns>True if the removal succeeded</returns> public void RemoveConnection(NetworkConnectionToClient conn) { connections.Remove(conn); }
private void OnServerAuthenticated(NetworkConnectionToClient connection) { // wait for client to send us an AddPlayerMessage connection.RegisterHandler <NetworkConnectionToClient, AddPlayerMessage>(OnServerAddPlayerInternal); }
// Callback used by the visibility system to determine if an observer // (player) can see the NetworkIdentity. If this function returns true, // the network connection will be added as an observer. // conn: Network connection of a player. // returns True if the player can see this object. public abstract bool OnCheckObserver(NetworkIdentity identity, NetworkConnectionToClient newObserver);