/// <summary> /// 群发给所有玩家地主牌以及地主ID /// </summary> /// <param name="LandLordID"></param> private void 发出_地主牌(int LandLordID) { byte[][] sendData; foreach (var player in _players) { sendData = new byte[][] { BitConverter.GetBytes(player.Key), BitConverter.GetBytes((int)DDZActions.S_地主牌), LandLordPoker.GetBuffer(), BitConverter.GetBytes(LandLordID) }; 发出消息(sendData); } }
public void GetBufferTest() { PokerGroup target = new PokerGroup(); // TODO: 初始化为适当的值 target.Add(new Poker(PokerNum.大王, PokerColor.红心)); target.Add(new Poker(PokerNum.P7, PokerColor.黑桃)); target.Add(new Poker(PokerNum.P3, PokerColor.梅花)); target.Add(new Poker(PokerNum.K, PokerColor.方块)); target.Add(new Poker(PokerNum.A, PokerColor.红心)); target.Add(new Poker(PokerNum.P4, PokerColor.黑桃)); target.Add(new Poker(PokerNum.P7, PokerColor.红心)); target.Add(new Poker(PokerNum.P9, PokerColor.红心)); byte[] expected = null; // TODO: 初始化为适当的值 byte[] actual; actual = target.GetBuffer(); string str = Encoding.Default.GetString(actual); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void GetBufferTest() { PokerGroup target = new PokerGroup(); // TODO: 初始化为适当的值 target.Add(new Poker(PokerNum.大王, PokerColor.红心)); target.Add(new Poker(PokerNum.P7, PokerColor.黑桃)); target.Add(new Poker(PokerNum.P3, PokerColor.梅花)); target.Add(new Poker(PokerNum.K, PokerColor.方块)); target.Add(new Poker(PokerNum.A, PokerColor.红心)); target.Add(new Poker(PokerNum.P4, PokerColor.黑桃)); target.Add(new Poker(PokerNum.P7, PokerColor.红心)); target.Add(new Poker(PokerNum.P9, PokerColor.红心)); byte[] expected = null; // TODO: 初始化为适当的值 byte[] actual; actual = target.GetBuffer(); string str = Encoding.Default.GetString(actual); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public static void 发送_出牌(PokerGroup pg) { byte[][] sendData = new byte[][] { BitConverter.GetBytes((int)DDZActions.C_出牌), pg.GetBuffer() }; 发送数据(sendData); }
/// <summary> /// 发送指定牌组和头信息给客户端 /// </summary> /// <param name="head">头信息</param> /// <param name="pg">牌组</param> /// <param name="client">客户端编号,只能是1,2</param> /// <returns>是否发送成功</returns> public bool SendDataForClient(string head, PokerGroup pg, int client) { NetworkStream Ns = null; if (client == 1) { Ns = this.client1.GetStream(); } if (client == 2) { Ns = this.client2.GetStream();//得到客户端的网络流对象 } if (client != 1 && client != 2) { return false; } byte[] bytePg = pg.GetBuffer(); //通过2个 MemoryStream对象获取代表2组牌的 比特流对象 string strPg = Encoding.Default.GetString(bytePg); string strSender = head + strPg; //组合两个字符串 byte[] byteSender = Encoding.Default.GetBytes(strSender); //把要发送的数据转换为byte[] Ns.Write(byteSender, 0, byteSender.Length); //把2个比特流对象写入server与client的连接管道中 Thread.Sleep(sleep); return true; }
/// <summary> /// 发送牌组给客户端 /// </summary> /// <param name="pg">牌组</param> /// <param name="client">客户端的编号,只能是1,2</param> /// <returns>是否发送成功</returns> public bool SendDataForClient(PokerGroup pg, int client) { NetworkStream Ns = null; if (client == 1) { Ns = this.client1.GetStream(); } if (client == 2) { Ns = this.client2.GetStream();//得到客户端的网络流对象 } if (client != 1 && client != 2) { return false; } byte[] bytePg = pg.GetBuffer(); //通过2个 MemoryStream对象获取代表2组牌的 比特流对象 Ns.Write(bytePg, 0, bytePg.Length); //把2个比特流对象写入server与client的连接管道中 Thread.Sleep(sleep); return true; }
public bool SendDataForServer(string head,PokerGroup pg) { NetworkStream Ns = client.GetStream(); byte[] bytePg = pg.GetBuffer(); //通过2个 MemoryStream对象获取代表2组牌的 比特流对象 string strPg = Encoding.Default.GetString(bytePg); string strSender = head + strPg; //组合两个字符串 byte[] byteSender = Encoding.Default.GetBytes(strSender); //把要发送的数据转换为byte[] Ns.Write(byteSender, 0, byteSender.Length); //把2个比特流对象写入server与client的连接管道中 Thread.Sleep(sleep); return true; }
public bool SendDataForServer(PokerGroup pg) { NetworkStream Ns = this.client.GetStream(); byte[] bytes = pg.GetBuffer(); Ns.Write(bytes, 0, bytes.Length); Thread.Sleep(sleep); return true; }
public static void 发送_出牌(PokerGroup pg) { byte[][] sendData = new byte[][] { BitConverter.GetBytes((int)DDZActions.C_出牌), pg.GetBuffer() }; 发送数据(sendData); }