0
https://github.com/mingchaoyan/chat
,如果你在BroadcastClient.cs改變SENDMSG到
void Send1(string inputString1) {
Proto.BroadcastProto proto = new Proto.BroadcastProto();
proto.userName = "Client";
proto.stringMsg =inputString1;
NetPacket p = new NetPacket();
p.BeginWrite("OnRevMsg");
p.WriteObject<Proto.BroadcastProto>(proto);
p.EncodeHeader();
networkManager.Send(p);
inputString = "";
}
void SendMsg() {
Send1 ("1");
Send1 ("22");
Send1 ("333");
Send1 ("4444");
Send1 ("55555");
Send1 ("666666");
Send1 ("7777777");
Send1 ("88888888");
}
僅僅是一次發送多個短信息,不發送一個像以前一樣得到1個。
這時你會發現在的debug.log幾乎OnRevMsg打印
"88888888"
8倍。
我打開了套接字,發現NetworkManager.packets(它是一個隊列)的元素在每次接收到新的msg時都會更改爲新接收的!
從套接字接收數據我有一些錯誤嗎?
BeginWrite是否存在匹配的EndWrite? –
@RonBeyer不,我認爲這就夠了 – mingchaoyan