You can download this code by clicking the button below.
This code is now available for download.
This function creates a simple WAMP (WebSocket Application Messaging Protocol) client that registers a remote procedure named `add`, which takes two arguments and returns their sum.
Technology Stack : Autobahn, WAMP
Code Type : The type of code
Code Difficulty : Intermediate
from random import randint
from autobahn.wamp import Application, ApplicationSession
from autobahn import wamp
def random_wamp_session():
class MyComponent(ApplicationSession):
def on_join(self, details):
print("Joined realm.")
self.register(self.add, u"com.myapp.add")
@wamp.register(u"com.myapp.add")
def add(self, x, y):
return x + y
app = Application(MyComponent, "ws://localhost:8080/ws")
app.run()