static void ServerOnRecv(int remoteID, byte[] accptBytes) { TOPBYTE topbyte = (TOPBYTE)accptBytes[0]; accptBytes = VisionFunctions.DeleteTopByte(accptBytes); if (topbyte == TOPBYTE.STRING) { string sendStr; sendStr = VisionFunctions.DeserializeToString(accptBytes); //fm1.Chat_Add(string.Format("server:client{0}からの通信>{1}", remoteID, accptStr)); sv.Broadcast(sendStr, TOPBYTE.STRING); } else if (topbyte == TOPBYTE.NETVISIONCORE) { NetvisionCore accptCore = new NetvisionCore(); accptCore.setAll(VisionFunctions.DeserializeToNetvisionCore(accptBytes)); if (remoteID == sv.player1) { sv.core.setAll(accptCore); } else if (remoteID == sv.player2) { sv.core.setAll(accptCore.ReverseSide()); } // 返信 sv.BroadcastCore(); } else if (topbyte == TOPBYTE.DECK) { Card[] accptDeck = new Card[50]; accptDeck = VisionFunctions.DeserializeToDeck(accptBytes); if (remoteID == sv.player1) { for (int i = 0; i < 50; i++) { sv.core.cards[i].setAll(accptDeck[i]); } } else if (remoteID == sv.player2) { for (int i = 0; i < 50; i++) { sv.core.cards[50 + i].setAll(accptDeck[i]); } } if (svStat == SERVERSTAT.PLAYING) { sv.StartGame(); sv.BroadcastCore(); } } else { string sendStr; sendStr = accptBytes.Length.ToString(); sv.Broadcast(sendStr, TOPBYTE.STRING); } }
public void Send(int remoteID, object sendObj, TOPBYTE topbyte) { byte[] sendBytes = VisionFunctions.Serialize(sendObj); sendBytes = VisionFunctions.SetTopByte(sendBytes, (byte)topbyte); try { Send(remoteID, sendBytes); } catch (Exception ex) { Program.fm1.Chat_Add(ex.Message); } }
public void Broadcast(object sendObj, TOPBYTE topbyte) { int i; for (i = 0; i < ConnectedList().Length; i++) { try { Send(i, sendObj, topbyte); } catch { Program.fm1.Chat_Add(string.Format("server:remote{0}へ送信できませんでした", i)); } } }
public void Broadcast(object sendObj,TOPBYTE topbyte) { int i; for (i = 0; i < ConnectedList().Length; i++) { try { Send(i, sendObj, topbyte); } catch { Program.fm1.Chat_Add(string.Format("server:remote{0}へ送信できませんでした", i)); } } }