[英]send image from websocket server .NET to client (HTML5)
I'm currently implementing websocket communication betweeb the server (VB .NET) and the client(web page) 我目前正在服务器(VB .NET)和客户端(网页)之间实现websocket通信
I succeeded in sending text from server to the client and display the text using JavaScript and canvas, 我成功地将文本从服务器发送到客户端,并使用JavaScript和canvas显示了文本,
Now I want to send an image from the server to be displayed in the HTML5 canvas, 现在,我想从服务器发送图像以显示在HTML5画布中,
The websocket server implementation I use is Fleck 我使用的websocket服务器实现是Fleck
any suggestion? 有什么建议吗? I lack binary/bmp knowledge 我缺乏二进制/ BMP知识
From a quick look at the Fleck source, you can send binary data using 快速浏览Fleck源代码,您可以使用
string imgFilePath = ...
socket.send(System.IO.File.ReadAllBytes(imgFilePath));
(where socket will be a member variable you store in the OnOpen
delegate of the IWebSocketConnection
passed to your server's Start
method) (其中,套接字将是您存储在传递给服务器的Start
方法的IWebSocketConnection
的OnOpen
委托中的成员变量)
Note that not all browsers support reading binary frames yet. 请注意,并非所有浏览器都支持读取二进制帧。 Recent versions of Chrome support it; Chrome的最新版本支持它; I'm not sure if any others do yet. 我不确定是否还有其他人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.