Exemplo n.º 1
0
 // Use this for initialization
 public void Start()
 {
     if (!GameSettings.Singleton.m_isSingle)
     {
         ShortConnect.Connect(GameSettings.Singleton.ServerIP, 10124, false);
     }
 }
Exemplo n.º 2
0
 // Update is called once per frame
 public void Update()
 {
     if (!GameSettings.Singleton.m_isSingle)
     {
         ShortConnect.Update(this);
         LongConnect.Update(this);
     }
 }
Exemplo n.º 3
0
    public static void CreateSesion(ShortNetPack sendPack, Action <ShortNetPack> callback)
    {
        if (m_parentGameObject == null)
        {
            m_parentGameObject = new GameObject("ShortConnectMgr");
            GameObject.DontDestroyOnLoad(m_parentGameObject);
        }

        string     sesionName = "Sesion" + (m_parentGameObject.transform.childCount + 1).ToString();
        GameObject sesionGo   = new GameObject(sesionName);

        sesionGo.transform.parent = m_parentGameObject.transform;

        ShortConnect connect = sesionGo.AddComponent <ShortConnect>();

        byte[] msgData = connect.BuildMsgPack(sendPack);
        connect.StartConnect(msgData, callback);
    }
Exemplo n.º 4
0
    public void SendPacket(Packet p, ENConnectionType type = ENConnectionType.enShortConnect)
    {
        if (GameSettings.Singleton.m_isSingle)
        {
            VirtualServer.Singleton.ProcessMessage(p);
        }
        else
        {
            switch (type)
            {
            case ENConnectionType.enLongConnect:
                LongConnect.SendPacket(p);
                break;

            case ENConnectionType.enShortConnect:
            default:
                ShortConnect.SendPacket(p);
                break;
            }
            Debug.Log("Send Msg ,id = " + p.PacketID + " type:" + type);
        }
    }