Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

{.networked.} procedures (not direct sends) send data to the connection that called the RPC #4

@RattleyCooper

Description

@RattleyCooper

Check the example here:

https://github.com/RattleyCooper/nettyrpc-1/tree/examples/example/authoritativeChatClient

The client displays it's own chat message as if it came from another person:

# client.nim
proc display_chat(name, message: string) {.networked.} =
  ## Display chat message from the server.
  eraseLine()
  echo fmt"{getClockStr()} {name} says: {message}"

proc send_chat(name, msg: string) =
  # If you want client actions to take place instantly, create a procedure 
  # to handle client-side logic and then dispatch the RPC.
  eraseLine()
  echo fmt"{getClockStr()} You said: {msg}"
  rpc("send_chat", (name: name, msg: msg))

it should call the rpc on other clients, but it is sent to the caller of the rpc as well. If you send a chat you will see both messages in the chat.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions