monkey_shoulder v0.2.0
Monkey Shoulder
Monkey Shoulder is a library for exposing functions over WebSockets asynchronously.
Installation
Add this to your application's shard.yml
:
dependencies:
monkey_shoulder:
github: grkek/monkey_shoulder
Usage
require "monkey_shoulder/application"
class Mathematics < MonkeyShoulder::Binding
@[Annotations::ExternalMethod]
def add(a : Int32, b : Int32)
a + b
end
@[Annotations::ExternalMethod]
def subtract(a : Int32, b : Int32)
a - b
end
@[Annotations::ExternalMethod]
def multiply(a : Int32, b : Int32)
a * b
end
@[Annotations::ExternalMethod]
def divide(a : Int32, b : Int32)
a / b
end
end
Log.setup(:debug)
app = MonkeyShoulder::Application.new(host: "0.0.0.0", port: 4000)
app.run
Run the server and connect to it using a WebSocket client at 'ws://localhost:4000/ws/socket'
{
"eTag": "00000000-0000-0000-0000-000000000000",
"body": {
"instructionName": "listBindings"
}
}
Send this payload to get all the bindnings, select the one above and use the ID below.
{
"eTag": "00000000-0000-0000-0000-000000000000",
"body": {
"id": "BINDING_ID",
"instructionName": "executeMethod",
"sourceCode": {
"methodName": "multiply",
"type": "EXTERNAL",
"arguments": {"a": 1, "b": 2}
}
}
}
Send this payload to the server and it will return the result, you can use the eTag value to track responses from the server.
Contributing
- Fork it (https://github.com/grkek/monkey_shoulder/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Giorgi Kavrelishvili - creator and maintainer
Repository
monkey_shoulder
Owner
Statistic
- 2
- 0
- 0
- 0
- 2
- 3 months ago
- August 26, 2022
License
MIT License
Links
Synced at
Fri, 22 Nov 2024 11:01:36 GMT
Languages