internal Task CompleteJoinAsync(CancellationToken ct) { var cts = new CancellationTokenSource(); var tcs = new TaskCompletionSource <bool>(); ct.Register(() => { cts.Cancel(); tcs.TrySetCanceled(); }); JoinCompleteEvent.Of(this._botBitsClient).WaitOneAsync(cts.Token).ContinueWith(task => { if (task.IsCanceled) { return; } cts.Cancel(); tcs.TrySetResult(true); }, CancellationToken.None); JoinFailureEvent.Of(this._botBitsClient).WaitOneAsync(cts.Token).ContinueWith(task => { if (task.IsCanceled) { return; } cts.Cancel(); tcs.TrySetException(new JoinException(task.Result.Title, task.Result.Reason)); }, CancellationToken.None); return(tcs.Task); }
static void Main() { var bot = new BotBitsClient(); ChatFormatsExtension.LoadInto(bot, new CakeChatSyntaxProvider("Bot")); CommandsExtension.LoadInto(bot, '!'); Login.Of(bot).AsGuest().JoinRoom("PW01"); InitEvent.Of(bot).WaitOneAsync().Wait(); JoinCompleteEvent.Of(bot).WaitOneAsync().Wait(); Thread.Sleep(Timeout.Infinite); }
public void On(JoinCompleteEvent e) { var channel = new ByteChannel<Player>(new CoinChannel()); channel.Receive += this.Channel_Receive; ThreadPool.QueueUserWorkItem(o => { while (true) { channel.Send(Encoding.UTF8.GetBytes(Console.ReadLine())); } }); }
public void On(JoinCompleteEvent e) { var bp = new ByteProtocol <Player>(this._byteChannel); var cc = new ChatChannel(new CompressionChannel <Player>(bp.RegisterProtocol("EE Chat"))); ThreadPool.QueueUserWorkItem(o => { while (true) { cc.Send(Console.ReadLine()); } }); cc.Receive += this.Cc_Receive; }
public void On(JoinCompleteEvent e) { var bp = new ByteProtocol<Player>(this._byteChannel); var cc = new ChatChannel(new CompressionChannel<Player>(bp.RegisterProtocol("EE Chat"))); ThreadPool.QueueUserWorkItem(o => { while (true) { cc.Send(Console.ReadLine()); } }); cc.Receive += this.Cc_Receive; }
public void On(JoinCompleteEvent e) { var channel = new ByteChannel <Player>(new CoinChannel()); channel.Receive += this.Channel_Receive; ThreadPool.QueueUserWorkItem(o => { while (true) { channel.Send(Encoding.UTF8.GetBytes(Console.ReadLine())); } }); }
public void On(JoinCompleteEvent e) { this._byteChannel = new ByteChannel<Player>(new CoinChannel()); var bp = new ByteProtocol<Player>(this._byteChannel); var up = new UserProtocol<Player>(bp.RegisterProtocol("ByetUserStreams.Demo"), p => (uint)p.UserId); var stream = new ByteStream(up.GetUserChannel(this.Players.OwnPlayer, this.Players.OwnPlayer)); { var writer = new StreamWriter(stream) {AutoFlush = true}; writer.Write("Hello world!\n"); var reader = new StreamReader(stream); ThreadPool.QueueUserWorkItem(o => { while (true) { Console.Write((char) reader.Read()); } }); } }
public void On(JoinCompleteEvent e) { this._byteChannel = new ByteChannel <Player>(new CoinChannel()); var bp = new ByteProtocol <Player>(this._byteChannel); var up = new UserProtocol <Player>(bp.RegisterProtocol("ByetUserStreams.Demo"), p => (uint)p.UserId); var stream = new ByteStream(up.GetUserChannel(this.Players.OwnPlayer, this.Players.OwnPlayer)); { var writer = new StreamWriter(stream) { AutoFlush = true }; writer.Write("Hello world!\n"); var reader = new StreamReader(stream); ThreadPool.QueueUserWorkItem(o => { while (true) { Console.Write((char)reader.Read()); } }); } }
private void On(JoinCompleteEvent e) { this.JoinComplete = true; }
private void OnJoinComplete(JoinCompleteEvent e) { Console.WriteLine("Join complete"); ScanForPlaygrounds(); }