不管是什么文本還是二進(jìn)制數(shù)據(jù),都是在onMessage里接收,沒(méi)有區(qū)別。
如果是websocket協(xié)議,發(fā)送二進(jìn)制數(shù)據(jù)需要設(shè)置一個(gè)標(biāo)記位,參考手冊(cè)http://doc.workerman.net/315305
已經(jīng)發(fā)送成功了,我直接在onMessage里面接收的,也成功了,但是他有大小設(shè)置,我設(shè)置了$connection->maxSendBufferSize但是還是報(bào)錯(cuò),這個(gè)問(wèn)題遇到過(guò)沒(méi)有???
<!doctype html>
<html lang="en">
<head>
<title>Document</title>
<input type='file' name='img' onchange='showlist(this.files)'/>
</head>
<body>
<script>
function showlist(files)
{
var reader = new FileReader();
var result;
var file=files;
reader.onload = function()
{
result = this.result;
}
reader.readAsBinaryString(file);
var ws = new WebSocket('ws://192.168.2.183:1234');
ws.onopen = function()
{
var uid = 'uid2';
ws.send(file);
};
ws.onmessage = function(e)
{
console.log(e.data);
};
}
</script>
<script>
</script>
</body>
</html>