Comments (5)
When sending binary data over the network and no binary-safe mechanism is available, you should encode it to base64 prior to transmission and decode it on the other end.
Regarding the invalid argument error I have no idea yet. Can you explain the difference between the two new Uint16Array
calls in more detail?
from protobuf.js.
I have solved this problem. arrayBuffer can't converted to Uint16Array, because the number of bytes of data buffer may be singular, such as arrayBuffer byteLength is 61, it can only converted to Uint8Array, but if arrayBuffer byteLength is 62 or other even, it can converted to Uint16Array or Uint8Array. Actually, We do not know the length of the buffer is even or base. So, we shouldn't use Uint16Array.
String.fromCharCode(), this function will returns a string created by using the specified sequence of Unicode values.but, in my server, it unacceptable string has been encoded, so, i set string to latin1 before i send it to server. So, solve all the problems.
from protobuf.js.
Ucchen. I am having a similar problem with my code as well. Do you by anychance have the code that you used to send the str via a socket. I am trying to do what you are doing but my python script is not recognizing the string that I am sending to it.
from protobuf.js.
doesn't recognizing the string? can you post more detail?
from protobuf.js.
var commandmessage = new MCM ({
"carrier_freq": 92343.3,
"num_spurs": 33333,
});
console.log (commandmessage);
var byteBuffer = commandmessage.encode();
var buffer = byteBuffer.toArrayBuffer();
chrome.sockets.udp.send(socketId, byteBuffer, "0.0.0.0", 9994, function(sendInfo) {
console.log ("PYTHON SIMULATOR INITIATED!");
console.log("sent " + sendInfo.bytesSent + " bytes");
});
}catch (err) {
console.log ("No data encoded");
}
Above is my code to send out the protobuf message
and below is my code in python to receive the protobuf message...
class MyUDPHandler(SocketServer.BaseRequestHandler):
def handle(self):
data = self.request[0].strip()
socket = self.request[1]
print "{} wrote:".format(self.client_address[0])
print data
socket.sendto(data.upper(), self.client_address)
if name == 'main':
HOST, PORT = "localhost", 9994
server = SocketServer.UDPServer((HOST, PORT), MyUDPHandler)
server.serve_forever()
from protobuf.js.
Related Issues (20)
- custom class is output undefined
- How to decode grpc-web-text
- Enum value ignored HOT 1
- Fails to parse "{" in options
- int64 precesion problem
- Enum reserved keyword removed when compiling proto from json
- Add Auth to Xhr fetch
- The problem with load
- Update from version 6.x.x to version 7.x.x
- not support eval and new Function()/Function() HOT 2
- how do you type decode(...)
- how do I type a namespace?
- how to fix property does not exist on type "Message<MessageType>"
- Cannot read properties of undefined (reading 'add') HOT 3
- protobuff.encode() does not work as expected
- Backport prototype setProperty checks to 6.11.3 HOT 5
- protobufjs-cli still pull older version of escodegen HOT 3
- [Feature Request] Explore all files in a folder/subfolder
- CVE-2022-25878 - Fix for version 5.0.3 HOT 3
- Decoding fails sometimes, logs attached HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf.js.