public WebsocketConnect(RtmpServer server, IWebSocketConnection connection, ushort clientID, SerializationContext context, ObjectEncoding encoding) { this.connection = connection; this.ClientID = clientID; this.StreamID = server.RequestStreamId(); IsPlaying = true; sendPing = connection.SendPing; connectTime = DateTime.UtcNow; connection.OnPong += d => callbackManager.SetResult(BitConverter.ToInt32(d, 0), null); connection.OnClose += () => { OnDisconnected(new ExceptionalEventArgs("Closed")); }; connection.OnError += (e) => { OnDisconnected(new ExceptionalEventArgs(e.Message, e)); }; var stream = new WebsocketStream(connection); writer = new FlvPacketWriter(new AmfWriter(stream, context), encoding); reader = new RtmpPacketReader(new AmfReader(stream, context)); //启动输出任务 writer.WriteLoopAsync(); }
public WebsocketConnect(IWebSocketConnection connection, IO.SerializationContext context, IO.ObjectEncoding encoding) { this.connection = connection; IsPlaying = true; sendPing = connection.SendPing; connectTime = DateTime.UtcNow; connection.OnPong += d => callbackManager.SetResult(BitConverter.ToInt32(d, 0), null); connection.OnClose += () => { OnDisconnected(new ExceptionalEventArgs("Closed")); }; connection.OnError += (e) => { OnDisconnected(new ExceptionalEventArgs(e.Message, e)); }; var stream = new WebsocketStream(connection); writer = new FlvPacketWriter(new IO.AmfWriter(stream, context), encoding); reader = new RtmpPacketReader(new IO.AmfReader(stream, context)); }