Exemplo n.º 1
0
 public Task FlushAsync(CancellationToken cancellationToken)
 {
     return(OutStream.FlushAsync(cancellationToken));
 }
Exemplo n.º 2
0
 public Task WriteAsync(byte value, CancellationToken cancellationToken)
 {
     Debug.Assert(value <= 18);
     return(OutStream.WriteAsync(ByteValueBuffer, value, 1, cancellationToken));
 }
Exemplo n.º 3
0
        public void WriteHeader(UsTarHeader header)
        {
            _headerPosition = OutStream.Position;

            OutStream.Write(header.GetHeaderValue(), 0, header.HeaderSize);
        }
Exemplo n.º 4
0
 public string WriteLine(string s)
 {
     OutStream.WriteLineAsync(s);
     return(s);
 }
Exemplo n.º 5
0
 public void WriteNull()
 {
     OutStream.WriteByte(0);
 }
Exemplo n.º 6
0
 public override IDisposable Subscribe(IObserver <CharactersOut> observer) => OutStream.Subscribe(observer);
Exemplo n.º 7
0
 public void TestReadThrowsIfBufferNotLargeEnough()
 {
     Proc.Read(IntPtr.Zero, OutStream.GetBuffer(), 10000);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Writes a packet to a stream.
        /// </summary>
        public static void Write(Packet Packet, OutStream Stream)
        {
            // Build flags and header
            PacketFlags flags = PacketFlags.Empty;
            if (Packet.AcknowledgementNumber.HasValue)
                flags |= PacketFlags.Acknowledgement;
            if (Packet.RoundTripTime.HasValue)
                flags |= PacketFlags.RoundTripTime;
            if (Packet.ChunkData != null)
            {
                flags |= PacketFlags.Chunk;
                if (Packet.ChunkInitial)
                    flags |= PacketFlags.ChunkInitial;
                if (Packet.ChunkFinal)
                    flags |= PacketFlags.ChunkFinal;
            }
            if (Packet.PingRequest)
                flags |= PacketFlags.PingRequest;
            if (Packet.PingResponse)
                flags |= PacketFlags.PingResponse;
            if (Packet.Disconnect)
                flags |= PacketFlags.Disconnect;
            Stream.WriteByte((byte)flags);
            Stream.WriteInt(Packet.SequenceNumber);

            // Additional information
            int ack;
            if (Packet.AcknowledgementNumber.TryGetValue(out ack))
                Stream.WriteInt(ack);

            double rtt;
            if (Packet.RoundTripTime.TryGetValue(out rtt))
                Stream.WriteDouble(rtt);

            // Chunk
            if (Packet.ChunkData != null)
                Stream.Write(Packet.ChunkData, 0, Packet.ChunkData.Length);
        }
Exemplo n.º 9
0
        public void testDisjointBuffers()
        {
            OutputCollector  collect = new OutputCollector();
            CompressionCodec codec   = new ZlibCodec();
            OutStream        @out    = new OutStream("test", 400, codec, collect);

            PositionCollector[] positions = new PositionCollector[1024];
            DataOutput          stream    = new DataOutputStream(@out);

            for (int i = 0; i < 1024; ++i)
            {
                positions[i] = new PositionCollector();
                @out.getPosition(positions[i]);
                stream.writeInt(i);
            }
            @out.Flush();
            Assert.Equal("test", @out.ToString());
            Assert.Equal(1674, collect.buffer.size());
            ByteBuffer[] inBuf = new ByteBuffer[3];
            inBuf[0] = ByteBuffer.allocate(500);
            inBuf[1] = ByteBuffer.allocate(1200);
            inBuf[2] = ByteBuffer.allocate(500);
            collect.buffer.setByteBuffer(inBuf[0], 0, 483);
            collect.buffer.setByteBuffer(inBuf[1], 483, 1625 - 483);
            collect.buffer.setByteBuffer(inBuf[2], 1625, 1674 - 1625);

            for (int i = 0; i < inBuf.Length; ++i)
            {
                inBuf[i].flip();
            }
            InStream @in = InStream.create(null, "test", inBuf,
                                           new long[] { 0, 483, 1625 }, 1674, codec, 400);

            Assert.Equal("compressed stream test position: 0 length: 1674 range: 0" +
                         " offset: 0 limit: 0 range 0 = 0 to 483;" +
                         "  range 1 = 483 to 1142;  range 2 = 1625 to 49",
                         @in.ToString());
            DataInputStream inStream = new DataInputStream(@in);

            for (int i = 0; i < 1024; ++i)
            {
                int x = inStream.readInt();
                Assert.Equal(i, x);
            }
            Assert.Equal(0, @in.available());
            for (int i = 1023; i >= 0; --i)
            {
                @in.seek(positions[i]);
                Assert.Equal(i, inStream.readInt());
            }

            @in = InStream.create(null, "test", new ByteBuffer[] { inBuf[1], inBuf[2] },
                                  new long[] { 483, 1625 }, 1674, codec, 400);
            inStream = new DataInputStream(@in);
            positions[303].reset();
            @in.seek(positions[303]);
            for (int i = 303; i < 1024; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }

            @in = InStream.create(null, "test", new ByteBuffer[] { inBuf[0], inBuf[2] },
                                  new long[] { 0, 1625 }, 1674, codec, 400);
            inStream = new DataInputStream(@in);
            positions[1001].reset();
            for (int i = 0; i < 300; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }
            @in.seek(positions[1001]);
            for (int i = 1001; i < 1024; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }
        }
Exemplo n.º 10
0
        public void testUncompressedDisjointBuffers()
        {
            OutputCollector collect = new OutputCollector();
            OutStream       @out    = new OutStream("test", 400, null, collect);

            PositionCollector[] positions = new PositionCollector[1024];
            DataOutput          stream    = new DataOutputStream(@out);

            for (int i = 0; i < 1024; ++i)
            {
                positions[i] = new PositionCollector();
                @out.getPosition(positions[i]);
                stream.writeInt(i);
            }
            @out.Flush();
            Assert.Equal("test", @out.ToString());
            Assert.Equal(4096, collect.buffer.size());
            ByteBuffer[] inBuf = new ByteBuffer[3];
            inBuf[0] = ByteBuffer.allocate(1100);
            inBuf[1] = ByteBuffer.allocate(2200);
            inBuf[2] = ByteBuffer.allocate(1100);
            collect.buffer.setByteBuffer(inBuf[0], 0, 1024);
            collect.buffer.setByteBuffer(inBuf[1], 1024, 2048);
            collect.buffer.setByteBuffer(inBuf[2], 3072, 1024);

            for (int i = 0; i < inBuf.Length; ++i)
            {
                inBuf[i].flip();
            }
            InStream @in = InStream.create(null, "test", inBuf,
                                           new long[] { 0, 1024, 3072 }, 4096, null, 400);

            Assert.Equal("uncompressed stream test position: 0 length: 4096" +
                         " range: 0 offset: 0 limit: 0",
                         @in.ToString());
            DataInputStream inStream = new DataInputStream(@in);

            for (int i = 0; i < 1024; ++i)
            {
                int x = inStream.readInt();
                Assert.Equal(i, x);
            }
            Assert.Equal(0, @in.available());
            for (int i = 1023; i >= 0; --i)
            {
                @in.seek(positions[i]);
                Assert.Equal(i, inStream.readInt());
            }

            @in = InStream.create(null, "test", new ByteBuffer[] { inBuf[1], inBuf[2] },
                                  new long[] { 1024, 3072 }, 4096, null, 400);
            inStream = new DataInputStream(@in);
            positions[256].reset();
            @in.seek(positions[256]);
            for (int i = 256; i < 1024; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }

            @in = InStream.create(null, "test", new ByteBuffer[] { inBuf[0], inBuf[2] },
                                  new long[] { 0, 3072 }, 4096, null, 400);
            inStream = new DataInputStream(@in);
            positions[768].reset();
            for (int i = 0; i < 256; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }
            @in.seek(positions[768]);
            for (int i = 768; i < 1024; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }
        }
Exemplo n.º 11
0
 public void WriteNullTerminatedStringUTF16(string value)
 {
     Write(Encoding.BigEndianUnicode.GetBytes(value));
     dataBuffer[0] = dataBuffer[1] = 0;
     OutStream.Write(dataBuffer, 0, sizeof(ushort));
 }
Exemplo n.º 12
0
 public override abstract void Serialize(OutStream outStream);
Exemplo n.º 13
0
 public override void OnSerialize(OutStream outStream)
 {
     outStream.WriteUnsignedShort(m_ProtocolID);
     Serialize(outStream);
 }
Exemplo n.º 14
0
 public Task WriteAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken)
 {
     return(OutStream.WriteAsync(buffer, index, count, cancellationToken));
 }
Exemplo n.º 15
0
 public void TestWriteThrowsOnApiError()
 {
     Proc.Read(IntPtr.Zero, OutStream.GetBuffer(), 4);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Writes an unsigned 16-bit integer in network byte order.
 /// </summary>
 /// <param name="value">value to write</param>
 public override void Write(ushort value)
 {
     buffer[0] = (byte)(value >> 8);
     buffer[1] = (byte)value;
     OutStream.Write(buffer, 0, 2);
 }
Exemplo n.º 17
0
 public static new void Write(Message Message, OutStream Stream)
 {
     DataRequestMessage drm = (DataRequestMessage)Message;
     ID.Write(drm.Index, Stream);
     DataRegion.Write(drm.Region, Stream);
     Bounty.Write(drm.Bounty, Stream);
 }
Exemplo n.º 18
0
 public abstract void Serialize(OutStream outStream);
Exemplo n.º 19
0
 /// <summary>
 /// Writes the given message to a stream.
 /// </summary>
 public static void Write(Message Message, OutStream Stream)
 {
     MessageType type = MessageType.ForType(Message.GetType());
     Stream.WriteByte(type.ID);
     type.Write(Message, Stream);
 }
Exemplo n.º 20
0
 public void WriteNullTerminatedString(string value)
 {
     Write(encoding.GetBytes(value));
     OutStream.WriteByte(0);
 }
Exemplo n.º 21
0
 public void Write(Message Message, OutStream Stream)
 {
     this._Write(Message, Stream);
 }
Exemplo n.º 22
0
 public void WriteContent(byte[] inBuffer, int offset, int count)
 {
     OutStream.Write(inBuffer, offset, count);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Writes a bounty to a stream.
 /// </summary>
 public static void Write(Bounty Bounty, OutStream Stream)
 {
     Stream.WriteDouble(Bounty.Base);
     Stream.WriteDouble(Bounty.Decay);
 }
Exemplo n.º 24
0
 public object WriteLine(object s)
 {
     OutStream.WriteLineAsync(s.ToString());
     return(s);
 }
Exemplo n.º 25
0
        void BuildMessageAdapterClassCSharp()
        {
            // Packer interface
            Parameter[] newparams;

            OpenSection("public class", String.Format("SendMessage{0} : SendMessage", Group.Name));

            BuildClassMember();
            BuildConstructor("SendMessage" + Group.Name);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildSendFunction(msg, "Cmd", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunction(msg, "C2SEvt", newparams); NewLine();
                    NewLine();
                }
            }

            MatchIndent(); OutStream.WriteLine("#region Native Interfaces ");
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildSendFunctionNativeInterface(msg, "Cmd", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeInterface(msg, "C2SEvt", newparams); NewLine();
                    NewLine();
                }
            }
            MatchIndent(); OutStream.WriteLine("#endregion //Native Interfaces ");

            CloseSection();



            OpenSection("public class", String.Format("SendMessageSvr{0} : SendMessage", Group.Name));

            BuildClassMember();
            BuildConstructor("SendMessageSvr" + Group.Name);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildSendFunction(msg, "Res", newparams); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunction(msg, "S2CEvt", newparams); NewLine();
                    NewLine();
                }
            }

            MatchIndent(); OutStream.WriteLine("#region Native Interfaces ");

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildSendFunctionNativeInterface(msg, "Res", newparams); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeInterface(msg, "S2CEvt", newparams); NewLine();
                    NewLine();
                }
            }
            MatchIndent(); OutStream.WriteLine("#endregion //Native Interfaces ");

            CloseSection();
        }
Exemplo n.º 26
0
        private void doCopyTo(File to, object exclude, object overwrite)
        {
            // check exclude
            if (exclude is Regex)
            {
                if (((Regex)exclude).matches(m_uri.toStr()))
                {
                    return;
                }
            }
            else if (exclude is Func)
            {
                if (((Func)exclude).call(this) == Boolean.True)
                {
                    return;
                }
            }

            // check for overwrite
            if (to.exists())
            {
                if (overwrite is Boolean)
                {
                    if (overwrite == Boolean.False)
                    {
                        return;
                    }
                }
                else if (overwrite is Func)
                {
                    if (((Func)overwrite).call(this) == Boolean.False)
                    {
                        return;
                    }
                }
                else
                {
                    throw IOErr.make("No overwrite policy for `" + to + "`").val;
                }
            }

            // copy directory
            if (isDir())
            {
                to.create();
                List kids = list();
                for (int i = 0; i < kids.sz(); ++i)
                {
                    File kid = (File)kids.get(i);
                    kid.doCopyTo(to.plusNameOf(kid), exclude, overwrite);
                }
            }

            // copy file contents
            else
            {
                OutStream @out = to.@out();
                try
                {
                    @in().pipe(@out);
                }
                finally
                {
                    @out.close();
                }
            }
        }
Exemplo n.º 27
0
 public virtual IDisposable Subscribe(IObserver <TConsoleOut> observer) => OutStream.Subscribe(observer);
Exemplo n.º 28
0
 public Task WriteAsync(bool value, CancellationToken cancellationToken)
 {
     return(OutStream.WriteAsync(ByteValueBuffer, value ? 1 : 0, 1, cancellationToken));
 }
Exemplo n.º 29
0
 public IDisposable Subscribe(IConsoleOutWriter writer) => OutStream.Subscribe(writer.Write, writer.Write, delegate { });
Exemplo n.º 30
0
 public Task WriteAsync(byte[] buffer, CancellationToken cancellationToken)
 {
     return(OutStream.WriteAsync(buffer, 0, buffer.Length, cancellationToken));
 }
Exemplo n.º 31
0
        public Stream GetDecryptedStream()
        {
            OutStream.Seek(0, SeekOrigin.Begin);

            return(OutStream);
        }
Exemplo n.º 32
0
        private void NetworkLoop(object ctxObject)
        {
            var ctx = (ConnectionContext)ctxObject;

            while (true)
            {
                lock (statusLock)
                {
                    if (ctx.WasExit)
                    {
                        break;
                    }
                }

                var packet = packetHandler.FetchPacket();
                if (packet == null)
                {
                    break;
                }

                lock (statusLock)
                {
                    if (ctx.WasExit)
                    {
                        break;
                    }

                    switch (packet.PacketType)
                    {
                    case PacketType.Command:
                    case PacketType.CommandLow:
                        string message = Util.Encoder.GetString(packet.Data, 0, packet.Data.Length);
                        LogCmd.Debug("[I] {0}", message);
                        var result = msgProc.PushMessage(message);
                        if (result.HasValue)
                        {
                            dispatcher.Invoke(result.Value);
                        }
                        break;

                    case PacketType.Voice:
                    case PacketType.VoiceWhisper:
                        OutStream?.Write(packet.Data, new Meta
                        {
                            In = new MetaIn
                            {
                                Whisper = packet.PacketType == PacketType.VoiceWhisper
                            }
                        });
                        break;

                    case PacketType.Init1:
                        // Init error
                        if (packet.Data.Length == 5 && packet.Data[0] == 1)
                        {
                            var errorNum = NetUtil.N2Huint(packet.Data, 1);
                            if (Enum.IsDefined(typeof(Ts3ErrorCode), errorNum))
                            {
                                Log.Info("Got init error: {0}", (Ts3ErrorCode)errorNum);
                            }
                            else
                            {
                                Log.Warn("Got undefined init error: {0}", errorNum);
                            }
                            DisconnectInternal(ctx, setStatus: Ts3ClientStatus.Disconnected);
                        }
                        break;
                    }
                }
            }

            lock (statusLock)
            {
                DisconnectInternal(ctx, setStatus: Ts3ClientStatus.Disconnected);
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// Print out a field
        /// </summary>
        /// <param name="f"></param>
        /// <param name="arr"></param>
        /// <returns>True if delim is needed</returns>
        public bool PrintField(Field f, string[] arr)
        {
            if (f.IsSingleField)
            {
                if (f.FieldNum < arr.Length)
                {
                    OutStream.Write(arr[f.FieldNum]);
                    return(true);
                }
                else
                {
                    // if want an empty field, return true
                    return(PrintEmptyFields);
                }
            }
            else if (f.IsAppend)
            {
                bool printed = false;
                for (int i = 0; i < f.FieldNums.Count; ++i)
                {
                    int n = f.FieldNums[i];
                    if (n < arr.Length)
                    {
                        OutStream.Write(arr[n]);
                        printed = true;
                    }
                }
                return(printed || PrintEmptyFields);
            }
            else if (f.AllFields)
            {
                for (int i = 0; i < arr.Length; ++i)
                {
                    if (i > 0)
                    {
                        OutStream.Write(OutDelimiter);
                    }
                    OutStream.Write(arr[i]);
                }
                return(true);
            }
            else if (f.Remaining)
            {
                bool needDelim = false;
                bool printed   = false;
                for (int i = 0; i < arr.Length; ++i)
                {
                    if (needDelim)
                    {
                        OutStream.Write(OutDelimiter);
                    }
                    needDelim = false;

                    // need to see if 'i' is somewhere else in Fields
                    bool printedElsewhere = false;
                    foreach (Field ff in Fields)
                    {
                        if (ff.IsSingleField && ff.FieldNum == i)
                        {
                            printedElsewhere = true;
                            break;
                        }
                    }
                    if (!printedElsewhere)
                    {
                        OutStream.Write(arr[i]);
                        printed   = true;
                        needDelim = true;
                    }
                }
                return(printed);
            }
            else
            {
                throw new Exception("Unexpected code");
            }
        }
Exemplo n.º 34
0
        public AudioClient(DiscordClient client, Server server, int id)
		{
            Id = id;
            _config = client.Config;
            Service = client.Services.Get<AudioService>();
            Config = Service.Config;
            Serializer = client.Serializer;
            _gatewayState = (int)ConnectionState.Disconnected;

            //Logging
            Logger = client.Log.CreateLogger($"AudioClient #{id}");

            //Async
            _taskManager = new TaskManager(Cleanup, false);
            _connectionLock = new AsyncLock();
            CancelToken = new CancellationToken(true);

            //Networking
            if (Config.EnableMultiserver)
            {
                ClientAPI = new JsonRestClient(_config, DiscordConfig.ClientAPIUrl, client.Log.CreateLogger($"ClientAPI #{id}"));
                GatewaySocket = new GatewaySocket(_config, client.Serializer, client.Log.CreateLogger($"Gateway #{id}"));
                GatewaySocket.Connected += (s, e) =>
                {
                    if (_gatewayState == ConnectionState.Connecting)
                        EndGatewayConnect();
                };
            }
            else
                GatewaySocket = client.GatewaySocket;
            GatewaySocket.ReceivedDispatch += (s, e) => OnReceivedEvent(e);
            VoiceSocket = new VoiceSocket(_config, Config, client.Serializer, client.Log.CreateLogger($"Voice #{id}"));
            VoiceSocket.Server = server;
            OutputStream = new OutStream(this);
        }
Exemplo n.º 35
0
        public int Run()
        {
            TextReader instream = null;

            try
            {
                OutStream = (WriteStdout ? Console.Out : new StreamWriter(FilenameOut));
                instream  = (ReadStdin ? Console.In : new StreamReader(FilenameIn));

                if (Verbose)
                {
                    for (int i = 0; i < Fields.Count; ++i)
                    {
                        Field f = Fields[i];
                        OutStream.WriteLine(String.Format("Field{0}|{1}|{2}|",
                                                          i,
                                                          f.VerboseType,
                                                          f.VerboseDefinition
                                                          )
                                            );
                    }
                }

                for (int row = 0; ; row++)
                {
                    string line = instream.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    string[] arr = ParseClass.ParseLine(line, TrimFields, Delimiter, PreserveQuotes, QuoteChar);
                    PrintFields(arr);
                    if (PrintTrailingDelim)
                    {
                        OutStream.Write(OutDelimiter);
                    }
                    OutStream.WriteLine();
                }

                return(0);
            }
            finally
            {
                if (instream != null && instream != Console.In)
                {
                    try { instream.Close(); }
                    catch { }
                    try { instream.Dispose(); }
                    catch { }
                }

                if (OutStream != null && OutStream != Console.Out)
                {
                    try { OutStream.Close(); }
                    catch { }
                    try { OutStream.Dispose(); }
                    catch { }
                }
            }
        }
Exemplo n.º 36
0
        public AudioClient(DiscordClient client, Server server, int id)
        {
            Id = id;
            Service = client.GetService<AudioService>();
            Config = Service.Config;
            Serializer = client.Serializer;
            _gatewayState = (int)ConnectionState.Disconnected;

            //Logging
            Logger = client.Log.CreateLogger($"AudioClient #{id}");

            //Async
            _taskManager = new TaskManager(Cleanup, false);
            _connectionLock = new AsyncLock();
            CancelToken = new CancellationToken(true);

            //Networking
            _config = client.Config;
            GatewaySocket = client.GatewaySocket;
            GatewaySocket.ReceivedDispatch += (s, e) => OnReceivedEvent(e);
            VoiceSocket = new VoiceSocket(_config, Config, client.Serializer, client.Log.CreateLogger($"Voice #{id}"));
            VoiceSocket.Server = server;
            OutputStream = new OutStream(this);
        }
Exemplo n.º 37
0
 public void Dispose()
 {
     InStream.Dispose();
     OutStream.Dispose();
 }