sta / websocket-sharp

A C# implementation of the WebSocket protocol client and server
http://sta.github.io/websocket-sharp
MIT License
5.73k stars 1.66k forks source link

multi-thread support? #338

Open DefinitlyEvil opened 7 years ago

DefinitlyEvil commented 7 years ago

currently each Send() will cause a lock to _forSend, so the data will transmit like this:

data1:frg1
data1:frg2
data2:frg1
data2:frg2
...

if multi-thread implemented, it should look like this:

data1:frg1
data2:frg1
data2:frg2
data1:frg2

but it may cause messages mis-ordered, maybe I should customize this protocol somehow.

253153 commented 7 years ago

I think I am running into this issue as well, is there a workaround?

DefinitlyEvil commented 7 years ago

Nah sry maybe it's just how WebSocket works to keep messages in order.

253153 commented 7 years ago

@DefinitlyEvil would commenting out the lock statements fix this at all?

253153 commented 7 years ago

@sta Do you have any input on this?

DefinitlyEvil commented 7 years ago

@deniskrop nope, I guess this protocol can't handle real-time data or big data.

253153 commented 7 years ago

@DefinitlyEvil Is there any way to modify it, or is there any implementation that does? I don't have any lag issues with an HTML5 + Javascript client that I wrote, but am seeing the lag in my Unity client using this library. Do you mean the whole websockets protocol or this library in particular? Some Unity multiplayer game examples use websockets-sharp and seem to run smoothly, not sure how accurate that is though. Could you point me in the right direction?

DefinitlyEvil commented 7 years ago

@deniskrop I meant the portocol, it is not suitable for huge data transmission. Well, there's no reason to fix it somehow, I just wrote my own thing. eg.: PACKET_HEADER(size and type) | PROTOBUF_ENCODED_DATA