Beispiel #1
0
 public void StartClient()
 {
     client.Connect(networkAddress, networkPort);
     clientID = 0;
     insightNetworkConnection = new InsightNetworkConnection();
     insightNetworkConnection.Initialize(this, networkAddress, clientID, connectionID);
     OnClientStart();
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
        void HandleConnect(Message msg)
        {
            // get ip address from connection
            string address = GetConnectionInfo(msg.connectionId);

            // add player info
            InsightNetworkConnection conn = new InsightNetworkConnection();

            conn.Initialize(this, address, serverHostId, msg.connectionId);
            AddConnection(conn);

            OnConnected(conn);
        }
Beispiel #4
0
        void HandleConnect(int connectionId)
        {
            logger.Log("[InsightServer] - Client connected connectionID: " + connectionId, this);

            // get ip address from connection
            string address = GetConnectionInfo(connectionId);

            // add player info
            InsightNetworkConnection conn = new InsightNetworkConnection();

            conn.Initialize(this, address, serverHostId, connectionId);
            AddConnection(conn);
        }
Beispiel #5
0
        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();
            }
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
 public virtual void OnDisconnected(InsightNetworkConnection conn)
 {
     Debug.Log("OnDisconnected");
 }
Beispiel #8
0
 void OnData(InsightNetworkConnection conn, byte[] data)
 {
     conn.TransportReceive(data);
 }
Beispiel #9
0
 public InsightNetworkMessage(InsightNetworkConnection conn, int callbackId)
 {
     this.callbackId = callbackId;
     this.conn       = conn;
 }
Beispiel #10
0
 public InsightNetworkMessage(InsightNetworkConnection conn)
 {
     this.conn = conn;
 }