示例#1
0
    void Start()
    {
        websocketConnection = gameObject.AddComponent <WebsocketConnection>();
        connectionAgent     = gameObject.AddComponent <ConnectionAgent>();

        connectionAgent.connection = websocketConnection;

        game = GameObject.FindObjectOfType <Game>();
    }
        private bool Login(string connectionUrl, string authApiKey)
        {
            bool isConnected = false;

            ConnectionAgent = ConnectionAgentWebServer.GetInstance(connectionUrl, authApiKey);
#if DEBUG
            isConnected = true;
            isConnected = ConnectionAgent.Connect(5000);
#else
            isConnected = ConnectionAgent.Connect(5000);
#endif

            return(isConnected);
        }
示例#3
0
 public static ConnectionAgent GetAgent()
 {
     lock (typeof(ChannelPool))
     {
         if (_agent != null && _agent.GetChannel().IsConnected)
         {
             return(_agent);
         }
         TcpTransportChannel channel = new TcpTransportChannel("172.16.20.18", 20200);
         channel.Connect();
         if (!channel.IsConnected)
         {
             return(null);
         }
         _agent = new ConnectionAgent(new MessageTransportChannel <BaseMessage>(channel, new BASProtocolStack()), Common.TransactionManager);
         return(_agent);
     }
 }
 public void Init(int playerId, ConnectionAgent agent)
 {
     this.playerId = playerId;
     this.agent    = agent;
 }