static void Main(string[] args) { _sm = new ServerMain(); _clients = new ClientConn[clientNo]; _askCounters = new TurnAskTimeCounter[clientNo]; for (int i = 0; i < clientNo; ++i) { _clients[i] = new ClientConn(); _clients[i].InitConnection("127.0.0.1", 1734); _askCounters[i] = new TurnAskTimeCounter(); _clients[i].MessageSend += new MessageEventHandler(_askCounters[i].OnMessageSend); _clients[i].MessageReceive += new MessageEventHandler(_askCounters[i].OnMessageRecieve); InitSend(i); } _clients[0].SendMessage(CreateCreateGameMessage()); for (int i = 1; i < clientNo; ++i) { _clients[i].SendMessage(CreateJoinMessage()); } Thread.Sleep(1000); for (int i = 0; i < clientNo; ++i) { _clients[i].SendMessage(MessageFactory.Create(MessageType.StartGame)); } for (int i = 0; i < clientNo; ++i) { ClientSendingThread cst = new ClientSendingThread(_clients[i]); Thread th = new Thread(new ThreadStart(cst.ThreadProcess)); th.Start(); } }
public ClientSendingThread(ClientConn conn) { cc = conn; }