Skip to content

Commit

Permalink
add address to args (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
elcritch authored Oct 27, 2024
1 parent 924772f commit f1231af
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nesper.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.7.6"
version = "0.7.7"
author = "Jaremy Creechley"
description = "Nim wrappers for ESP-IDF (ESP32)"
license = "Apache-2.0"
Expand Down
3 changes: 2 additions & 1 deletion src/nesper/servers/rpc/rpcsocket_json.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ proc rpcMsgPackReadHandler*(srv: TcpServerInfo[RpcRouter], result: ReadyKey, sou
echo("control server: error: socket timeout: ", $sourceClient.getFd().int)


proc startRpcSocketServer*(port: Port; router: var RpcRouter) =
proc startRpcSocketServer*(port: Port; address="", router: var RpcRouter) =
logi(TAG, "starting json rpc server: buffer: %s", $router.buffer)

startSocketServer[RpcRouter](
port,
address=address,
readHandler=rpcMsgPackReadHandler,
writeHandler=rpcMsgPackWriteHandler,
data=router)
Expand Down
3 changes: 2 additions & 1 deletion src/nesper/servers/rpc/rpcsocket_mpack.nim
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ proc rpcMsgPackReadHandler*(srv: TcpServerInfo[RpcRouter], result: ReadyKey, sou
echo("control server: error: socket timeout: ", $sourceClient.getFd().int)


proc startRpcSocketServer*(port: Port; router: var RpcRouter) =
proc startRpcSocketServer*(port: Port; address="", router: var RpcRouter) =
logi(TAG, "starting mpack rpc server: buffer: %s", $router.buffer)

startSocketServer[RpcRouter](
port,
address=address,
readHandler=rpcMsgPackReadHandler,
writeHandler=rpcMsgPackWriteHandler,
data=router)
Expand Down
4 changes: 2 additions & 2 deletions src/nesper/servers/tcpsocket.nim
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ proc echoReadHandler*(srv: TcpServerInfo[string], result: ReadyKey, sourceClient
for cfd, client in srv.clients:
client.sendWrap(data & message & "\r\L")

proc startSocketServer*[T](port: Port, readHandler: TcpServerHandler[T], writeHandler: TcpServerHandler[T], data: var T) =
proc startSocketServer*[T](port: Port, address: string = "", readHandler: TcpServerHandler[T], writeHandler: TcpServerHandler[T], data: var T) =
var server: Socket = newSocket()
var select: Selector[T] = newSelector[T]()

server.setSockOpt(OptReuseAddr, true)
server.getFd().setBlocking(false)
server.bindAddr(port)
server.bindAddr(port, address=address)
server.listen()

logi TAG, "Server: started. Listening to new connections on port: %s", $port
Expand Down

0 comments on commit f1231af

Please sign in to comment.