public override Task Join(MultiplayerGame game) { return(Task.Factory.StartNew(() => { if (!Started) { throw new InvalidOperationException("Chord is not started!"); } _channel = _manager.JoinChannel(game.Id, this); _game = game; })); }
public override Task Host(MultiplayerGame game) { game.Id = Guid.NewGuid().ToString("N"); return(Start().ContinueWith(t => { if (t.IsFaulted) { throw t.Exception.InnerExceptions.First(); } _game = game; _channel = _manager.JoinChannel(game.Id, this); })); }
public override void Stop() { if (_manager != null) { _manager.Stop(); if (_publicChannel != null) { _manager.LeaveChannel(_publicChannel.Name); _publicChannel.Dispose(); _publicChannel = null; } if (_channel != null) { _manager.LeaveChannel(_channel.Name); _channel.Dispose(); _channel = null; } _game = null; Started = false; } }
/// <summary> /// Connects to an existing game /// </summary> public virtual Task Join(MultiplayerGame game) { return(Task.Delay(1000)); }