public bool AddConnection(InsightNetworkConnection conn) { if (!connections.ContainsKey(conn.connectionId)) { // connection cannot be null here or conn.connectionId // would throw NRE connections[conn.connectionId] = conn; conn.SetHandlers(messageHandlers); return(true); } // already a connection with this id return(false); }
public virtual void Start() { Application.runInBackground = true; clientID = 0; insightNetworkConnection = new InsightNetworkConnection(); insightNetworkConnection.Initialize(this, networkAddress, clientID, connectionID); insightNetworkConnection.SetHandlers(messageHandlers); transport.OnClientConnected = OnConnected; transport.OnClientDataReceived = HandleBytes; transport.OnClientDisconnected = OnDisconnected; transport.OnClientError = OnError; if (AutoStart) { StartInsight(); } }
public virtual void Start() { if (DontDestroy) { DontDestroyOnLoad(this); } Application.runInBackground = true; if (AutoStart) { StartInsight(); } clientID = 0; insightNetworkConnection = new InsightNetworkConnection(); insightNetworkConnection.Initialize(this, networkAddress, clientID, connectionID); insightNetworkConnection.SetHandlers(messageHandlers); transport.OnClientConnected.AddListener(OnConnected); transport.OnClientDataReceived.AddListener(HandleBytes); transport.OnClientDisconnected.AddListener(OnDisconnected); transport.OnClientError.AddListener(OnError); }