コード例 #1
0
        public static async void HandleDisconnectRequest(DisconnectRequest disconnectRequest, BnetSession session)
        {
            Log.Message(LogTypes.Info, $"Client '{session.GetClientInfo()} disconnected ({disconnectRequest.ErrorCode}).");

            await session.Send(new DisconnectNotification
            {
                ErrorCode = disconnectRequest.ErrorCode,
            }, BnetServiceHash.ConnectionService, 4);
        }
コード例 #2
0
        // TODO: Implement Replication

        /*
         * /// <summary>
         * /// Configures replication writebacks to ADW
         * /// </summary>
         * /// <param name="request"></param>
         * /// <param name="context"></param>
         * /// <returns></returns>
         * public override Task<ConfigureReplicationResponse> ConfigureReplication(ConfigureReplicationRequest request,
         *  ServerCallContext context)
         * {
         *  Logger.SetLogPrefix("configure_replication");
         *  Logger.Info($"Configuring write for schema name {request.Schema.Name}...");
         *
         *  var schemaJson = Write.GetSchemaJson();
         *  var uiJson = Write.GetUIJson();
         *
         *  try
         *  {
         *      var errors = new List<string>();
         *      if (!string.IsNullOrWhiteSpace(request.Form.DataJson))
         *      {
         *          // check for config errors
         *          var replicationFormData =
         *              JsonConvert.DeserializeObject<ConfigureReplicationFormData>(request.Form.DataJson);
         *
         *          replicationFormData.Owner = _server.Settings.Username.ToUpper();
         *
         *          errors = replicationFormData.ValidateReplicationFormData();
         *
         *          return Task.FromResult(new ConfigureReplicationResponse
         *          {
         *              Form = new ConfigurationFormResponse
         *              {
         *                  DataJson = JsonConvert.SerializeObject(replicationFormData),
         *                  Errors = { errors },
         *                  SchemaJson = schemaJson,
         *                  UiJson = uiJson,
         *                  StateJson = request.Form.StateJson
         *              }
         *          });
         *      }
         *
         *      return Task.FromResult(new ConfigureReplicationResponse
         *      {
         *          Form = new ConfigurationFormResponse
         *          {
         *              DataJson = request.Form.DataJson,
         *              Errors = { },
         *              SchemaJson = schemaJson,
         *              UiJson = uiJson,
         *              StateJson = request.Form.StateJson
         *          }
         *      });
         *  }
         *  catch (Exception e)
         *  {
         *      Logger.Error(e, e.Message, context);
         *
         *      return Task.FromResult(new ConfigureReplicationResponse
         *      {
         *          Form = new ConfigurationFormResponse
         *          {
         *              DataJson = request.Form.DataJson,
         *              Errors = { e.Message },
         *              SchemaJson = schemaJson,
         *              UiJson = uiJson,
         *              StateJson = request.Form.StateJson
         *          }
         *      });
         *  }
         * }
         *
         * /// <summary>
         * /// Prepares writeback settings to write to ADW
         * /// </summary>
         * /// <param name="request"></param>
         * /// <param name="context"></param>
         * /// <returns></returns>
         * public override async Task<PrepareWriteResponse> PrepareWrite(PrepareWriteRequest request,
         *  ServerCallContext context)
         * {
         *  // Logger.SetLogLevel(Logger.LogLevel.Debug);
         *  Logger.SetLogPrefix(request.DataVersions.JobId);
         *  Logger.Info("Preparing write...");
         *  _server.WriteConfigured = false;
         *
         *  _server.WriteSettings = new WriteSettings
         *  {
         *      CommitSLA = request.CommitSlaSeconds,
         *      Schema = request.Schema,
         *      Replication = request.Replication,
         *      DataVersions = request.DataVersions,
         *  };
         *
         *  if (_server.WriteSettings.IsReplication())
         *  {
         *      // reconcile job
         *      Logger.Info($"Starting to reconcile Replication Job {request.DataVersions.JobId}");
         *      try
         *      {
         *          await Replication.ReconcileReplicationJobAsync(_connectionFactory, request);
         *      }
         *      catch (Exception e)
         *      {
         *          Logger.Error(e, e.Message, context);
         *          return new PrepareWriteResponse();
         *      }
         *
         *      Logger.Info($"Finished reconciling Replication Job {request.DataVersions.JobId}");
         *  }
         *
         *  _server.WriteConfigured = true;
         *
         *  Logger.Debug(JsonConvert.SerializeObject(_server.WriteSettings, Formatting.Indented));
         *  Logger.Info("Write prepared.");
         *  return new PrepareWriteResponse();
         * }
         *
         *
         * /// <summary>
         * /// Writes records to ADW
         * /// </summary>
         * /// <param name="requestStream"></param>
         * /// <param name="responseStream"></param>
         * /// <param name="context"></param>
         * /// <returns></returns>
         * public override async Task WriteStream(IAsyncStreamReader<Record> requestStream,
         *  IServerStreamWriter<RecordAck> responseStream, ServerCallContext context)
         * {
         *  try
         *  {
         *      Logger.Info("Writing records to Oracle ADW...");
         *
         *      var schema = _server.WriteSettings.Schema;
         *      var inCount = 0;
         *
         *      // get next record to publish while connected and configured
         *      while (await requestStream.MoveNext(context.CancellationToken) && _server.Connected &&
         *             _server.WriteConfigured)
         *      {
         *          var record = requestStream.Current;
         *          inCount++;
         *
         *          Logger.Debug($"Got record: {record.DataJson}");
         *
         *          if (_server.WriteSettings.IsReplication())
         *          {
         *              var config =
         *                  JsonConvert.DeserializeObject<ConfigureReplicationFormData>(_server.WriteSettings
         *                      .Replication
         *                      .SettingsJson);
         *
         *              // send record to source system
         *              // add await for unit testing
         *              // removed to allow multiple to run at the same time
         *              Task.Run(
         *                  async () => await Replication.WriteRecordAsync(_connectionFactory, schema, record, config,
         *                      responseStream), context.CancellationToken);
         *          }
         *          else
         *          {
         *              // send record to source system
         *              // add await for unit testing
         *              // removed to allow multiple to run at the same time
         *              // Task.Run(async () =>
         *              //         await Write.WriteRecordAsync(_connectionFactory, schema, record, responseStream),
         *              //     context.CancellationToken);
         *          }
         *      }
         *
         *      Logger.Info($"Wrote {inCount} records to Oracle ADW.");
         *  }
         *  catch (Exception e)
         *  {
         *      Logger.Error(e, e.Message, context);
         *  }
         * }
         */

        /// <summary>
        /// Handles disconnect requests from the agent
        /// </summary>
        /// <param name="request"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Task <DisconnectResponse> Disconnect(DisconnectRequest request, ServerCallContext context)
        {
            // clear connection
            _server.Connected = false;
            _server.Settings  = null;

            // alert connection session to close
            if (_tcs != null)
            {
                _tcs.SetResult(true);
                _tcs = null;
            }

            Logger.Info("Disconnected");
            return(Task.FromResult(new DisconnectResponse()));
        }
コード例 #3
0
        //
        public override Task <DisconnectReply> Disconnect(DisconnectRequest request, ServerCallContext context)
        {
            Client client = GetClientByConnectionId(request.ConnectionId);

            clients.Remove(request.ConnectionId);

            BoardcastAsync(new PlayerConnectionEvent
            {
                Type     = PlayerConnectionEvent.Types.Type.Disconnect,
                Username = client.Username,
            });

            return(Task.FromResult(new DisconnectReply
            {
            }));
        }
コード例 #4
0
        public async Task ConnectSessionTest()
        {
            // setup
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When("https://creator.zoho.com/api/json/applications?scope=creatorapi&authtoken=mocktoken")
            .Respond("application/json",
                     "{\"result\":{\"application_list\":{\"applications\":[{\"application\":[{\"created_time\":\"2019-03-1305:29:27.0\",\"application_name\":\"EventManagement\",\"access\":\"private\",\"link_name\":\"event-management\",\"time_zone\":\"IST\",\"dateformat\":\"dd-MMM-yyyy\"}]}]},\"application_owner\":\"wyattroehler\"}}");

            Server server = new Server
            {
                Services = { Publisher.BindService(new PluginZohoCreator.Plugin.Plugin(mockHttp.ToHttpClient())) },
                Ports    = { new ServerPort("localhost", 0, ServerCredentials.Insecure) }
            };

            server.Start();

            var port = server.Ports.First().BoundPort;

            var channel = new Channel($"localhost:{port}", ChannelCredentials.Insecure);
            var client  = new Publisher.PublisherClient(channel);

            var request           = GetConnectSettings();
            var disconnectRequest = new DisconnectRequest();

            // act
            var response       = client.ConnectSession(request);
            var responseStream = response.ResponseStream;
            var records        = new List <ConnectResponse>();

            while (await responseStream.MoveNext())
            {
                records.Add(responseStream.Current);
                client.Disconnect(disconnectRequest);
            }

            // assert
            Assert.Single(records);

            // cleanup
            await channel.ShutdownAsync();

            await server.ShutdownAsync();
        }
コード例 #5
0
ファイル: ChatHub.cs プロジェクト: ewol123/chat.net
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            try
            {
                await base.OnDisconnectedAsync(exception);

                var request = new DisconnectRequest();
                request.socketId = Context.ConnectionId;
                var response = await _userService.Disconnect(request);

                await Groups.RemoveFromGroupAsync(Context.ConnectionId, response.roomIdentifier.ToString());

                await Clients.OthersInGroup(response.roomIdentifier.ToString()).BrLeftRoom(response);
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
            }
        }
コード例 #6
0
        public async Task ConnectSessionTest()
        {
            // setup
            var mockHttp = GetMockHttpMessageHandler();

            Server server = new Server
            {
                Services = { Publisher.BindService(new PluginSalesforce.Plugin.Plugin(mockHttp.ToHttpClient())) },
                Ports    = { new ServerPort("localhost", 0, ServerCredentials.Insecure) }
            };

            server.Start();

            var port = server.Ports.First().BoundPort;

            var channel = new Channel($"localhost:{port}", ChannelCredentials.Insecure);
            var client  = new Publisher.PublisherClient(channel);

            var request           = GetConnectSettings();
            var disconnectRequest = new DisconnectRequest();

            // act
            var response       = client.ConnectSession(request);
            var responseStream = response.ResponseStream;
            var records        = new List <ConnectResponse>();

            while (await responseStream.MoveNext())
            {
                records.Add(responseStream.Current);
                client.Disconnect(disconnectRequest);
            }

            // assert
            Assert.Single(records);

            // cleanup
            await channel.ShutdownAsync();

            await server.ShutdownAsync();
        }
コード例 #7
0
        public IObservable <string> Execute(
            [CanBeNull] string commandLine,
            out Guid commandGuid,
            CancellationToken token = default(CancellationToken))
        {
            if (_clientTask == null ||
                State != PipeState.Connected ||
                string.IsNullOrWhiteSpace(commandLine))
            {
                commandGuid = Guid.Empty;
                // ReSharper disable once AssignNullToNotNullAttribute
                return(Observable.Empty <string>());
            }

            // We intercept disconnect commands and convert to a proper disconnect request for a cleaner disconnect.
            // This isn't technically necessary, but it means that the connection requests the disconnect rather than
            // the server disconnecting the connection - which is how the command works.
            if (_disconnectCommands.Contains(commandLine.Trim()))
            {
                DisconnectRequest disconnect = new DisconnectRequest();
                commandGuid = disconnect.ID;
                // ReSharper disable once AssignNullToNotNullAttribute
                return(Send(disconnect, token)
                       .Select(c => string.Empty)
                       .IgnoreElements());
            }

            // ReSharper disable once AssignNullToNotNullAttribute
            CommandRequest command = new CommandRequest(commandLine);

            commandGuid = command.ID;
            // ReSharper disable once AssignNullToNotNullAttribute
            return(Send(command, token)
                   .Cast <CommandResponse>()
                   // ReSharper disable once PossibleNullReferenceException
                   .Select(r => r.Chunk)
                   .Where(c => !string.IsNullOrEmpty(c)));
        }
コード例 #8
0
ファイル: UserService.cs プロジェクト: ewol123/chat.net
        /**
         * Leave a room the user is currently in.
         */
        public async Task <DisconnectResponse> Disconnect(DisconnectRequest payload)
        {
            try
            {
                var response = new DisconnectResponse();

                User user = await _userRepository.FindRoomOfUserBySocketId(payload.socketId);

                if (user == null)
                {
                    throw new ApplicationError("[UserService.Disconnect]", 1);
                }

                if (user.room == null)
                {
                    throw new ApplicationError("[UserService.Disconnect]", 2);
                }

                var room  = user.room;
                var users = await _userRepository.FindAllByRoomId(room.id);

                user.room = null;

                response.roomIdentifier = room.identifier;
                response.users          = users.Where(
                    (roomUser) => roomUser.socketId != payload.socketId
                    );

                await _unitOfWork.Save();

                return(response);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #9
0
        /// <summary>
        /// Stops all data transmition and disconnectes the TcpClient
        /// </summary>
        private void Disconnect()
        {
            foreach (var client in Server.Receivers.Where(x => x != this && x.Status != StatusEnum.Disconnected))
            {
                DisconnectRequest msg = new DisconnectRequest();
                msg.SenderClient = this.ClientName;
                client.SendMessage(msg);
            }

            if (Status == StatusEnum.Disconnected)
            {
                return;
            }

            //if (OtherSideReceiver != null)
            //{
            //    OtherSideReceiver.OtherSideReceiver = null;
            //    OtherSideReceiver.Status = StatusEnum.Validated;
            //    OtherSideReceiver = null;
            //}
            Status = StatusEnum.Disconnected;
            Client.Client.Disconnect(false);
            Client.Close();
        }
コード例 #10
0
ファイル: BaseService.cs プロジェクト: rosebud/mooege
 public override void RequestDisconnect(IRpcController controller, DisconnectRequest request, Action<NO_RESPONSE> done)
 {
     ProtoOutputBuffer.Write(request.GetType(), request.ToString());
 }
コード例 #11
0
 public static unsafe void Write(global::Improbable.Worker.Internal.GcHandlePool _pool,
                                 DisconnectRequest _data, global::Improbable.Worker.CInterop.SchemaObject _obj)
 {
 }
コード例 #12
0
 public override void RequestDisconnect(IRpcController controller, DisconnectRequest request, Action <NO_RESPONSE> done)
 {
     ProtoOutputBuffer.Write(request.GetType(), request.ToString());
 }
コード例 #13
0
            /// <summary>
            /// Starts this instance.
            /// </summary>
            public void Start()
            {
                CancellationTokenSource cts = _cancellationTokenSource;

                if (cts == null)
                {
                    return;
                }

                CancellationToken token = cts.Token;

                _serverTask = Task.Run(
                    async() =>
                {
                    // The disconnect GUID can be set by a disconnect request if the client requests it.
                    Guid disconnectGuid = Guid.Empty;

                    // Create pipe access rule to allow everyone to connect - may want to change this later
                    try
                    {
                        // Create pipe stream.
                        using (OverlappingPipeServerStream stream = new OverlappingPipeServerStream(
                                   _server.Name,
                                   _server.MaximumConnections,
                                   PipeTransmissionMode.Message,
                                   InBufferSize,
                                   OutBufferSize,
                                   _server._pipeSecurity))
                        {
                            _state = PipeState.Open;

                            // Wait for connection
                            await stream.Connect(token).ConfigureAwait(false);

                            if (!token.IsCancellationRequested)
                            {
                                // Connect this connection to the service.
                                _connectionGuid = _server.Service.Connect(this);

                                if (_connectionGuid != Guid.Empty)
                                {
                                    ConnectRequest connectRequest = null;

                                    // Set the stream.
                                    _stream = stream;

                                    _server.Add();
                                    _state = PipeState.AwaitingConnect;

                                    try
                                    {
                                        // Keep going as long as we're connected.
                                        while (stream.IsConnected &&
                                               !token.IsCancellationRequested &&
                                               _server.Service.State != ServiceControllerStatus.Stopped &&
                                               _connectionGuid != Guid.Empty)
                                        {
                                            // Read data in.
                                            byte[] data = await stream.ReadAsync(token).ConfigureAwait(false);
                                            if (data == null ||
                                                token.IsCancellationRequested ||
                                                _server.Service.State == ServiceControllerStatus.Stopped ||
                                                _connectionGuid == Guid.Empty)
                                            {
                                                break;
                                            }

                                            // Deserialize the incoming message.
                                            Message message = Message.Deserialize(data);

                                            Request request = message as Request;

                                            // We only accept requests, anything else is a protocol error and so we must disconnect.
                                            if (request == null)
                                            {
                                                break;
                                            }

                                            if (connectRequest == null)
                                            {
                                                // We require a connect request to start
                                                connectRequest = request as ConnectRequest;
                                                if (connectRequest == null)
                                                {
                                                    break;
                                                }

                                                _state = PipeState.Connected;
                                                _connectionDescription = connectRequest.Description;
                                                Log.Add(
                                                    LoggingLevel.Notification,
                                                    () => ServiceResources.Not_NamedPipeConnection_Connection,
                                                    _connectionDescription);

                                                await Send(
                                                    new ConnectResponse(request.ID, _server.Service.ServiceName),
                                                    token)
                                                .ConfigureAwait(false);
                                                continue;
                                            }

                                            CommandRequest commandRequest = request as CommandRequest;
                                            if (commandRequest != null)
                                            {
                                                if (!string.IsNullOrWhiteSpace(commandRequest.CommandLine))
                                                {
                                                    _commands.TryAdd(
                                                        commandRequest.ID,
                                                        new ConnectedCommand(
                                                            _connectionGuid,
                                                            _server.Service,
                                                            this,
                                                            commandRequest,
                                                            token));
                                                }
                                                continue;
                                            }

                                            CommandCancelRequest commandCancelRequest =
                                                request as CommandCancelRequest;
                                            if (commandCancelRequest != null)
                                            {
                                                ConnectedCommand cancelled;
                                                if (_commands.TryRemove(
                                                        commandCancelRequest.CancelCommandId,
                                                        out cancelled))
                                                {
                                                    // ReSharper disable once PossibleNullReferenceException
                                                    cancelled.Cancel(commandCancelRequest);
                                                }
                                                continue;
                                            }

                                            DisconnectRequest disconnectRequest = request as DisconnectRequest;
                                            if (disconnectRequest != null)
                                            {
                                                // Set the guid for disconnect.
                                                disconnectGuid = disconnectRequest.ID;
                                                break;
                                            }
                                        }
                                    }
                                    catch (TaskCanceledException)
                                    {
                                    }

                                    if (stream.IsConnected)
                                    {
                                        try
                                        {
                                            // Try to send disconnect response.
                                            using (CancellationTokenSource dts = Constants.FireAndForgetTokenSource)
                                                await Send(
                                                    new DisconnectResponse(disconnectGuid),
                                                    dts.Token)
                                                .ConfigureAwait(false);
                                        }
                                        catch (TaskCanceledException)
                                        {
                                        }
                                    }
                                }
                            }

                            // Remove the stream.
                            _stream = null;
                            _state  = PipeState.Closed;
                        }
                    }
                    catch (TaskCanceledException)
                    {
                        // Don't log cancellation.
                    }
                    catch (IOException ioe)
                    {
                        if (!token.IsCancellationRequested)
                        {
                            // Common exception caused by sudden disconnect, lower level
                            Log.Add(
                                ioe,
                                LoggingLevel.Information,
                                () => ServiceResources.Err_NamedPipeConnection_Failed);
                        }
                    }
                    catch (Exception exception)
                    {
                        if (!token.IsCancellationRequested)
                        {
                            Log.Add(
                                exception,
                                LoggingLevel.Error,
                                () => ServiceResources.Err_NamedPipeConnection_Failed);
                        }
                    }
                    finally
                    {
                        Dispose();
                    }
                },
                    token);
            }
コード例 #14
0
 public override void RequestDisconnect(IRpcController controller, DisconnectRequest request, Action <bnet.protocol.NO_RESPONSE> done)
 {
     throw new NotImplementedException();
 }
コード例 #15
0
        public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
        {
            switch (methodId)
            {
            case 1:
            {
                ConnectRequest  request  = ConnectRequest.Parser.ParseFrom(stream);
                ConnectResponse response = new ConnectResponse();

                BattlenetRpcErrorCode status = HandleConnect(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Connect(bgs.protocol.connection.v1.ConnectRequest: {1}) returned bgs.protocol.connection.v1.ConnectResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 2:
            {
                BindRequest request = new BindRequest();
                request.MergeFrom(stream);

                BindResponse          response = new BindResponse();
                BattlenetRpcErrorCode status   = HandleBind(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Bind(bgs.protocol.connection.v1.BindRequest: {1}) returned bgs.protocol.connection.v1.BindResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 3:
            {
                EchoRequest request = new EchoRequest();
                request.MergeFrom(stream);

                EchoResponse          response = new EchoResponse();
                BattlenetRpcErrorCode status   = HandleEcho(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Echo(bgs.protocol.connection.v1.EchoRequest: {1}) returned bgs.protocol.connection.v1.EchoResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 4:
            {
                DisconnectNotification request = DisconnectNotification.Parser.ParseFrom(stream);

                BattlenetRpcErrorCode status = HandleForceDisconnect(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.ForceDisconnect(bgs.protocol.connection.v1.DisconnectNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 5:
            {
                NoData request = NoData.Parser.ParseFrom(stream);

                BattlenetRpcErrorCode status = HandleKeepAlive(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.KeepAlive(bgs.protocol.NoData: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 6:
            {
                EncryptRequest request = EncryptRequest.Parser.ParseFrom(stream);

                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleEncrypt(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Encrypt(bgs.protocol.connection.v1.EncryptRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 7:
            {
                DisconnectRequest request = DisconnectRequest.Parser.ParseFrom(stream);

                BattlenetRpcErrorCode status = HandleRequestDisconnect(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.RequestDisconnect(bgs.protocol.connection.v1.DisconnectRequest: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            default:
                Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
                SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
                break;
            }
        }
コード例 #16
0
        DisconnectResponse IEasConnection.Disconnect(DisconnectRequest disconnectRequest)
        {
            DisconnectCommand disconnectCommand = new DisconnectCommand(this.EasConnectionSettings);

            return(disconnectCommand.Execute(disconnectRequest));
        }
コード例 #17
0
ファイル: Connection.cs プロジェクト: modulexcite/capi.net
 public IAsyncResult BeginHangUp(AsyncCallback callback, object state) {
     try {
         Message request = null;
         switch (_status) {
             case ConnectionStatus.Connected:
             case ConnectionStatus.B_ConnectPending:
                 _inititator = true;
                 request = new DisconnectB3Request(_ncci);
                 break;
             case ConnectionStatus.D_Connected:
             case ConnectionStatus.D_ConnectPending:
             case ConnectionStatus.B_DisconnectPending:
                 _inititator = true;
                 request = new DisconnectRequest(_plci);
                 break;
             default:
                 throw Error.NotSupported();
         }
         MessageAsyncResult result = new MessageAsyncResult(this, request, callback, state);
         _application.SendRequestMessage(result);
         return result;
     } catch (Exception e) {
         Trace.TraceError("Connection#{0}::BeginHangUp, Exception = {1}", ValidationHelper.HashString(this), e);
         throw;
     }
 }
コード例 #18
0
ファイル: ConnectionServiceImpl.cs プロジェクト: fry/d3
		public override void RequestDisconnect(IRpcController controller, DisconnectRequest request, Action<bnet.protocol.NO_RESPONSE> done) {
			throw new NotImplementedException();
		}
コード例 #19
0
        public IObservable<string> Execute(
            [CanBeNull] string commandLine,
            out Guid commandGuid,
            CancellationToken token = default(CancellationToken))
        {
            if (_clientTask == null ||
                State != PipeState.Connected ||
                string.IsNullOrWhiteSpace(commandLine))
            {
                commandGuid = Guid.Empty;
                // ReSharper disable once AssignNullToNotNullAttribute
                return Observable.Empty<string>();
            }

            // We intercept disconnect commands and convert to a proper disconnect request for a cleaner disconnect.
            // This isn't technically necessary, but it means that the connection requests the disconnect rather than
            // the server disconnecting the connection - which is how the command works.
            if (_disconnectCommands.Contains(commandLine.Trim()))
            {
                DisconnectRequest disconnect = new DisconnectRequest();
                commandGuid = disconnect.ID;
                // ReSharper disable once AssignNullToNotNullAttribute
                return Send(disconnect, token)
                    .Select(c => string.Empty)
                    .IgnoreElements();
            }

            // ReSharper disable once AssignNullToNotNullAttribute
            CommandRequest command = new CommandRequest(commandLine);
            commandGuid = command.ID;
            // ReSharper disable once AssignNullToNotNullAttribute
            return Send(command, token)
                .Cast<CommandResponse>()
                // ReSharper disable once PossibleNullReferenceException
                .Select(r => r.Chunk)
                .Where(c => !string.IsNullOrEmpty(c));
        }
コード例 #20
0
 private async Task HandleDisconnectRequestAsync(DisconnectRequest request)
 {
     Logger.LogWarning($"The server requested a disconnect!\n" +
                       $"Reason: {request.Reason}");
     await RestartConnectionAsync();
 }
コード例 #21
0
 DisconnectResponse IEasConnection.Disconnect(DisconnectRequest disconnectRequest)
 {
     return(this.innerConnection.Disconnect(disconnectRequest));
 }
コード例 #22
0
ファイル: Connection.cs プロジェクト: modulexcite/capi.net
 internal void DisconnectB3Indication(DisconnectB3Indication indication) {
     try {
         _ncci = INVAL_NCCI;
         DisconnectB3Response response = new DisconnectB3Response(indication);
         _application.SendMessage(response);
         Status = ConnectionStatus.D_Connected;
         if (_inititator) {
             DisconnectRequest request = new DisconnectRequest(_plci);
             _application.SendMessage(request);
         } 
     } catch (Exception e) {
         Trace.TraceError("Connection#{0}::DisconnectB3Indication, Exception = {1}", ValidationHelper.HashString(this), e);
         throw;
     }
 }
コード例 #23
0
ファイル: BaseService.cs プロジェクト: ncoop23/mooege
 public override void RequestDisconnect(Google.ProtocolBuffers.IRpcController controller, DisconnectRequest request, Action<NO_RESPONSE> done)
 {
     throw new NotImplementedException();
 }        
コード例 #24
0
ファイル: BaseService.cs プロジェクト: rdavydov/d3sharp
 public override void RequestDisconnect(Google.ProtocolBuffers.IRpcController controller, DisconnectRequest request, Action <NO_RESPONSE> done)
 {
     throw new NotImplementedException();
 }