我们再看看原生的WebSocket,写个WebSocket通讯Demo kybs00/WebSocketDemo (github.com)
服务端定时1ms使劲往客户端发送Message消息,结果竟然是:
System.InvalidOperationException:“There is already one outstanding 'SendAsync' call for this WebSocket instance. ReceiveAsync and SendAsync can be called simultaneously, but at most one outstanding operation for each of them is allowed at the same time.”
看来发送事件外部也要处置惩罚好高并发的场景,1ms真的是太猛了
1 private SemaphoreSlim _sendLock = new SemaphoreSlim(1);