kalm / kalm.js

The socket manager

Home Page:http://kalm.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Own framing?

freehuntx opened this issue · comments

Atm im trying to write a client for a game (TCP) with a special structure.

[Header]
- key<int8>
- reserved<int8>
- packetSize<int16le>
- encrypted<int8>
[Body]
- body<buffer[packetSize - 5]>

For me it looks like Kalm uses an own hardcoded framing.
Would it be possible to make that configurable?
Or is Kalm supposed to just connect with other Kalm endpoints?

You are right, it uses it's own framing to route packets, so yeah it's only designed to work with other kalm endpoints.

That being said, you can still use kalm to send raw binary packets by passing serial: null in the options. This skips serialization.

Hmm but it still provides some kind of framing.
This example:

const Net = require('net')
const Kalm = require('kalm')

Net.createServer(socket => {
  socket.on('data', data => console.log(data))
}).listen(1337)

const client = Kalm.connect({
  hostname: '127.0.0.1',
  port: 1337,
  transport: Kalm.transports.TCP,
  serial: null
})

client.write('', Buffer.from('lol'))

returns a buffer of: 00 00 00 01 00 03 6c 6f 6c

But i would expect: 6c 6f 6c

The kalm framing is necessary and will be added to binary payloads too. Like I said, it needs to interact with othe kalm endpoints.

It's the only way it's able to perform call buffering and routing.

If your project doesn't allow you to use kalm everywhere then unfortunately you wont be able to use it.

Alright, thanks for the info :)