async public void Write(object sender, ChessEventArgs e) { if (stream != null) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using (MemoryStream ms = new MemoryStream()) { binaryFormatter.Serialize(ms, e); var buffer = ms.ToArray(); await stream.WriteAsync(buffer, 0, buffer.Length); } } }
public virtual void Move(int x, int y, Field f) { Figure figure = f.GetFigure(new Point(x, y)); if (figure != null && figure.Color != Color) { f.Remove(figure); } ChessEventArgs chessEventArgs = new ChessEventArgs(x, y, X, Y); X = x; Y = y; TurnNotify?.Invoke(this, chessEventArgs); }