Exemple #1
0
 private void ConnectHandler(LNReq_Connect msg, PBChannel channel, int handle, uint seq)
 {
     if (!Enable)
     {
         LogSys.Log(LOG_TYPE.ERROR, "Connect to DataStorNode while DataOperator is Disable");
         return;
     }
     try
     {
         bool   ret      = true;
         string errorMsg = string.Empty;
         LogSys.Log(LOG_TYPE.INFO, "DataStoreClient connect :{0} ", msg.ClientName);
         var reply = NLRep_Connect.CreateBuilder();
         reply.SetResult(ret);
         reply.SetError(errorMsg);
         channel.Send(reply.Build());
     }
     catch (Exception e)
     {
         var reply = NLRep_Connect.CreateBuilder();
         reply.SetResult(false);
         reply.SetError(e.Message);
         channel.Send(reply.Build());
     }
 }
Exemple #2
0
        public void Connect(string clientName, ConnectCallback cb)
        {
            connect_callback_ = cb;
            if (current_status == ConnectStatus.Connecting || current_status == ConnectStatus.Connected)
            {
                return;
            }
            string        error       = null;
            LNReq_Connect connectData = null;

            try {
                LNReq_Connect.Builder connectBuilder = LNReq_Connect.CreateBuilder();
                connectBuilder.SetClientName(clientName);
                connectData = connectBuilder.Build();
            }
            catch (Exception e) {
                error = e.Message;
            }
            if (null != error)
            {
                cb(false, error);
                return;
            }
            if (!channel_.Send(connectData))
            {
                cb(false, "unknown");
            }
            else
            {
                current_status = ConnectStatus.Connecting;
                //connectOpt_timeout_.Add(session, cb, () => cb(false, "connect request timeout"));
            }
        }
Exemple #3
0
 private void ConnectHandler(LNReq_Connect msg, PBChannel channel, int handle, uint seq)
 {
     try {
         bool   ret      = true;
         string errorMsg = string.Empty;
         LogSys.Log(LOG_TYPE.INFO, "GMServerClient connect :{0} ", msg.ClientName);
         var reply = NLRep_Connect.CreateBuilder();
         reply.SetResult(ret);
         reply.SetError(errorMsg);
         channel.Send(reply.Build());
     } catch (Exception e) {
         var reply = NLRep_Connect.CreateBuilder();
         reply.SetResult(false);
         reply.SetError(e.Message);
         channel.Send(reply.Build());
     }
 }