我有一个问题,我的Asp.Net Core RC1项目中的Startup.cs类中有我的Websocket方法。
private async Task Echo(WebSocket webSocket)
{
var buffer = new byte[1024 * 4];
var result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
string text = "";
while (!result.CloseStatus.HasValue)
{
await webSocket.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None);
result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
for (int i = 0; i < result.Count; i++)
{
text += (char) buffer[i];
}
/*
TODO: ADD {text} to Database
*/
text = text ?? "";
}
await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
}
我需要通过Entity Framework 7将变量文本传递给我的数据库,但我有问题。我怎么能这样做?