/// <inheritdoc />
        public override async Task <GrpcResponse> StreamDisconnected(string streamID)
        {
            await CommonSubscriptionHandler.UnregisterStream(streamID);

            CommonBaseHandler.Log(this.ToString(), string.Format("Client stream {0} disconnted.", streamID), LogLevel.Info);
            return(Ok());
        }
Пример #2
0
        /// <summary>
        /// Starts the server.
        /// </summary>
        /// <param name="srcDeviceId">The source device identifier.</param>
        /// <param name="communicationService">The communication service.</param>
        private void StartServer(string srcDeviceId, IServer <Command, FetchRequest, GrpcResponse> communicationService)
        {
            // Grpc server
            CommunicationServer server = new CommunicationServer(communicationService, srcDeviceId);

            // Grpc server actions
            server.OnAction       = async(cmd, streamId, token, header) => { return(await ActionWorker.ProcessCommand(srcDeviceId, cmd, streamId, token, header)); };
            server.OnFetch        = async(request, streamId, token, header) => { return(await FetchWorker.ProcessFetch(request, streamId, token, header)); };
            server.OnStreamOpened = async(stream, token, header) => { return(await ActionWorker.StreamConnected(stream, token, header)); };
            server.OnStreaming    = async(cmd, stream, token, header) =>
            {
                return(await ActionWorker.ProcessCommand(srcDeviceId, cmd, stream.Id, token, header));
            };
            server.OnClientDisconnected = async(id) =>
            {
                await CommonSubscriptionHandler.UnregisterStream(id);
            };
            server.OnLog += (sender, srcid, msg, level) =>
            {
                CommonBaseHandler.Log(sender.ToString(), msg, level);
            };
            server.Start();
        }