You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm experiencing an issue with my implementation of message framing. I've read the other issue (#3) and practically did the same thing, but the server tends to crash at random times.
This is the code from my server.
privatevoidSendData(stringjson){byte[]data= Serialization.GroBuf.Serialize(json);byte[]sizeInfo=newbyte[4];
sizeInfo[0]=(byte) data.Length;
sizeInfo[1]=(byte)(data.Length >>8);
sizeInfo[2]=(byte)(data.Length >>16);
sizeInfo[3]=(byte)(data.Length >>24);
SendAsync(sizeInfo);
SendAsync(data);}privatelong_totalRead;privatebool_receivingMessage;privateint_messageSize;privatebyte[]_fullMessage;protectedoverrideasyncvoidOnReceived(byte[]buffer,longoffset,longsize){if(!_receivingMessage&&size==4){_messageSize |= buffer[offset+0];_messageSize |= buffer[offset+1]<<8;_messageSize |= buffer[offset+2]<<16;_messageSize |= buffer[offset+3]<<24;_receivingMessage=true;_fullMessage=newbyte[_messageSize];}elseif(_messageSize!=0){
Array.Copy(buffer, offset, _fullMessage, _totalRead, size);// System.ArgumentException: Destination array was not long enough. Check the destination index, length, and the array's lower bounds. (Parameter 'destinationArray')_totalRead+=size;if(_messageSize!=_totalRead)return;await HandleData(_fullMessage);_fullMessage=null;_messageSize=0;_receivingMessage=false;_totalRead=0;}}
Any help is appreciated, thank you.
The text was updated successfully, but these errors were encountered:
I'm experiencing an issue with my implementation of message framing. I've read the other issue (#3) and practically did the same thing, but the server tends to crash at random times.
This is the code from my server.
Any help is appreciated, thank you.
The text was updated successfully, but these errors were encountered: