// TODO Pass in cancellation token??
        public async Task ServerToTransporter(Guid id, SocketPacket packet)
        {
            if (packet == null)
            {
                throw new ArgumentNullException(nameof(packet));
            }

            await ConnectionDictionary[id].Socket.SendAsync(packet.Data.AsSpan().ToArray(), (WebSocketMessageType)packet.MessageType, packet.EndOfMessage, CancellationToken.None).ConfigureAwait(false);
        }
Example #2
0
        public async Task SendAsync(ArraySegment <byte> buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
        {
            if (buffer.Array == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            var socketPacket = new SocketPacket()
            {
                MessageType = messageType, EndOfMessage = endOfMessage, Data = ImmutableArray.Create(buffer.Array), Count = buffer.Count
            };

            await privateServerHubConnection.HubConnection.InvokeAsync(Strings.ServerToTransporter, this.socketConnection.Id, socketPacket).ConfigureAwait(false);
        }