예제 #1
0
 void OnDestroy()
 {
     foreach (var pair in networkMap)
     {
         RPCNetwork network = pair.Value;
         network.CutOff();
     }
 }
예제 #2
0
    void Awake()
    {
        _perspectiveProjection = Camera.main.GetComponent <PerspectiveProjection>();
        _leftCursorScript      = leftCursor.GetComponent <NSCursor>();
        _rightCursorScript     = rightCursor.GetComponent <NSCursor>();

        _NSObjects = new Dictionary <string, GameObject>();

        _NSNetwork = this.gameObject.GetComponent <RPCNetwork>();
    }
예제 #3
0
    /// <summary>
    /// Try connecting to server
    /// </summary>
    public void BeginConnect(NetType netType, string host, int port)
    {
        if (!networkMap.ContainsKey(netType))
        {
            CreateNetWork(netType, OnResponceNetMsg, OnNetException);
        }
        RPCNetwork network = networkMap[netType];

        if (network == null)
        {
            Debug.Log(string.Format("NetType{0:D} craete failed", (int)netType));
            return;
        }
        network.DoConnect(host, port);
    }
예제 #4
0
    /// <summary>
    /// Submit NetMsg to client, called per frame
    /// </summary>
    void SubmitNetMsg(NetType netType)
    {
        if (!msgBufferMap.ContainsKey(netType))
        {
            return;
        }
        List <NetMsgDef> msgList = msgBufferMap[netType];

        if (msgList.Count < 1)
        {
            return;
        }
        RPCNetwork network = networkMap[netType];

        network.SubmitNetMsg(msgList);
        msgList.Clear();
    }
예제 #5
0
    /// <summary>
    /// Create a instance of RPCNetwork
    /// </summary>
    public void CreateNetWork(NetType netType, RPCResponceCallback responceCallback, RPCExceptionCallback exceptionCallback)
    {
        RPCNetwork network = new RPCNetwork(netType, responceCallback, exceptionCallback);

        networkMap.Add(netType, network);
    }