Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Example Tour Reg/Call Lesson 3 Works - collections of types
s = backend.call("iWantManyStrings", ["This", "is", "cool"]).wait(str)
print s # Expects a str, like "Thanks for 3 strings!"
# End Example Tour Reg/Call Lesson 3 Works
# Example Tour Reg/Call Lesson 3 Fails - collections of types
try:
s = backend.call("iWantManyInts", [0, 1, "two"]).wait(str)
print s
except riffle.Error as e:
print e # Expects a str, like "wamp.error.invalid_argument: Cumin: expecting primitive int, got string"
# End Example Tour Reg/Call Lesson 3 Fails
######################################################################################
# Example Tour Reg/Call Lesson 4 Basic Student - intro to classes
class Student(riffle.ModelObject):
name = "Student Name"
age = 20
studentID = 0
s = Student()
s.name = "John Smith"
s.age = 18
s.studentID = 1234
backend.call("sendStudent", s).wait()
# End Example Tour Reg/Call Lesson 4 Basic Student
# Example Tour Reg/Call Lesson 4 Student Functions - intro to class functions
class Student(riffle.ModelObject):
name, age, studentID = "Student Name", 20, 0
s = Student()
s.name, s.age, s.studentID = "John Smith", 18, 1234
s = backend.call("changeStudentID", s).wait(Student)
def onJoin(self):
# Example Pub/Sub Basic - This is a basic pub/sub
backend.publish("basicSub", "Hello")
# End Example Pub/Sub Basic
# Example Pub/Sub Objects - This tests sending an object using pub/sub
class Stuff(riffle.ModelObject):
name = "This guy"
s = Stuff()
backend.publish("objectSub", s)
# End Example Pub/Sub Objects
######################################################################################
# Example Tour Reg/Call Lesson 4 Basic Student - intro to classes
class Student(riffle.ModelObject):
name = "Student Name"
age = 20
studentID = 0
def __str__(self):
return "{}, Age: {}, ID: {}".format(self.name, self.age, self.studentID)
@want(Student)
def sendStudent(s):
print s # Expects a str, like "John Smith, Age: 18, ID: 1234"
self.register("sendStudent", sendStudent)
# End Example Tour Reg/Call Lesson 4 Basic Student
# Example Tour Reg/Call Lesson 4 Student Functions - intro to class functions
class Student(riffle.ModelObject):
name, age, studentID = "Student Name", 20, 0
def changeID(self, newID):
self.studentID = 5678
@want(Student)
def changeStudentID(s):
print s.studentID # Expects an int, like 1234
s.changeID(5678)
return s
self.register("changeStudentID", changeStudentID)
# End Example Tour Reg/Call Lesson 4 Student Functions
print "___SETUPCOMPLETE___"
import riffle
from riffle import want
riffle.SetFabricLocal()
riffle.SetLogLevelInfo()
class User(riffle.ModelObject):
name = "John Doe"
email = 'bil@gmail.com'
def sayHello(self):
print 'Im ' + self.name + ', email me at ' + self.email
class Receiver(riffle.Domain):
def onJoin(self):
print "Receiver Joined"
self.subscribe("1", self.subscription)
self.register("2", self.registration)