Пример #1
0
    //public void SendMessageHall(short protocal, short protocalType, MemoryStream buf, string key)
    //{
    //    if (protocal == Protocal.ContractTypes.Heartbeat)
    //    {
    //        //Debug.Log("Hall--heartbeat");
    //    }
    //    Debug.Log("Hall--protocal============" + protocal);
    //    short messageID = MessageID;
    //    timeOutList.Add(new MessageTimeOut(ServerType.Hall, protocal, messageID, Time.unscaledTime));
    //    if (buf.Length == 0)
    //    {
    //        HallSocketClient.SendMessage(protocal, messageID, null, key);
    //    }
    //    else
    //    {
    //        byte[] data = new byte[buf.Length];
    //        buf.Position = 0;
    //        buf.Read(data, 0, data.Length);
    //        HallSocketClient.SendMessage(protocal, messageID, data, key);
    //    }
    //}

    private void SendMessageLogic(short protocal, short protocalType, MemoryStream buf, string key = "")
    {
        if (!LogicSocketClient.IsConnect)
        {
            Util.LogForNet("Socket 未连接无法发送消息");
            return;
        }
        if (protocal == Protocal.ContractTypes.Heartbeat)
        {
            //Debug.Log("BT7--heartbeat");
        }
        Util.LogForNet("===Send Message of Protocal NO." + protocal);
        short messageID = MessageID;

        timeOutList.Add(new MessageTimeOut(ServerType.Logic, protocal, messageID, Time.unscaledTime));
        if (buf.Length == 0)
        {
            LogicSocketClient.SendMessage(protocal, messageID, null, key);
        }
        else
        {
            byte[] data = new byte[buf.Length];
            buf.Position = 0;
            buf.Read(data, 0, data.Length);
            LogicSocketClient.SendMessage(protocal, messageID, data, key);
        }
    }
Пример #2
0
    /// <summary>
    /// 关闭连接
    /// </summary>
    public void Close()
    {
        // AppFacade.Instance.RemoveCommand(NotiConst.DISPATCH_MESSAGE);
        //Debug.LogWarning("Close the HallSocketClient");
        //HallSocketClient.Close();
        Debug.LogWarning("Close the LogicSocketClient");
        LogicSocketClient.Close();
        timeOutList.Clear();
        isStopUpdate = true;

        sEvents.Clear();
        //hallSocket = null;
        //bt7Socket = null;
    }
Пример #3
0
 void OnDestroy()
 {
     //HallSocketClient.OnRemove();
     LogicSocketClient.OnRemove();
     Debug.Log("~NetworkManager was destroy");
 }
Пример #4
0
    /// <summary>
    /// 发送大厅链接请求
    /// </summary>
    //public void SendConnectHall(string address, int port)
    //{
    //    HallSocketClient.SendConnect(address, port);
    //}

    /// <summary>
    /// 发送BT7链接请求
    /// </summary>
    public void SendConnectLogic(string address, int port)
    {
        Util.LogForNet("Connect to IP:" + address + " Port:" + port);
        LogicSocketClient.SendConnect(address, port);
    }
Пример #5
0
    //public void InitHallSocket()
    //{
    //    HallSocketClient.Close();
    //    HallSocketClient.OnRegister(ClientType.Hall);
    //}

    public void InitLogicSocket()
    {
        LogicSocketClient.Close();
        LogicSocketClient.OnRegister(ServerType.Logic);
    }
Пример #6
0
 public void Init()
 {
     //HallSocketClient.OnRegister(ClientType.Hall);
     LogicSocketClient.OnRegister(ServerType.Logic);
 }