Antano » Antano Server API » WebRTCService
Antano® will be released very soon. This is an announcement text

Contents

Search

WebRTCService

class services.WebRTCService(_server, _params, _type=<SocketKind.SOCK_DGRAM: 2>, _family=<AddressFamily.AF_UNSPEC: 0>)

Bases: services.SocketService

WebRtcService inits a websocket service with a specific endpoint and port and specific settings for handling web-rtc calls

Parameters:{obj} -- Service Base Class (Service) –

Methods Summary

add_accept_handler(sock, callback) Accept Handler for UDP Socket
add_sockets(sockets) Adds speficic sockets to the server
bind(port[, address, family]) Bind a specific socket (here UDP) to the server
bind_unix_socket(file, mode) Special binding for UnixSockets - the way unix-sockets are reused depends extremly on OS Platform
can_send() Basic info wether service can send back or not
close() Basic close service
get_service(_params[, _server]) Gets a service from service params EXAMPLE: _params[‘active_service’].append({ # tcp service “id”: 2, “antano_server_id”: 1, # needs to be the same as id above “service_type_id”: 2, “port”: 18002, “host”: “0.0.0.0”, “endpoint”: “”, # in case of rest or websocket /my_endpoint put “my_endpoint” “message_format_in_id”: 1, # message_format “message_format_out_id”: 1, # message_format })
get_ws_with_id(_id, _room) Helper function for getting a ws from id
make(endpoint) make app - creates a tornado endpoint with a given class
make_room(endpoint) make app - creates a tornado endpoint with a given class
on_received_message(message, address, …) On received message will process the message and if there is a repsonse it will send back to the same stream the client has send
run_processes(_services, _num_of_process) Finally runs all processes for given sockets this is mandatory for creating port bindings after creating sub-processes
send_message(message, address, stream[, …]) Basic send message from service
start(_params[, _internal]) basic start function
stop() Stops a service immediately

Methods Documentation

add_accept_handler(sock, callback)

Accept Handler for UDP Socket

Parameters:
  • {socket} -- Socket object (sock) –
  • {function} -- callBackFunction (callback) –
Keyword Arguments:
 

{IOLoop Obj} -- Current IOLoop (default (io_loop) – {None})

add_sockets(sockets)

Adds speficic sockets to the server

Parameters:{[Dict]} -- Dict of Sockets (sockets) –
bind(port, address=None, family=<AddressFamily.AF_UNSPEC: 0>)

Bind a specific socket (here UDP) to the server

Parameters:

{int} -- [port number] (port) –

Keyword Arguments:
 
  • {string} -- [Address string] (default (address) – {None})
  • {Socket.Family} -- [Socket.Family] (default (family) – {socket.AF_UNSPEC})
  • {int} -- [description] (default (backlog) – {25})
bind_unix_socket(file, mode)

Special binding for UnixSockets - the way unix-sockets are reused depends extremly on OS Platform

Parameters:
  • {string} -- file name (file) –
  • {int} -- chmod mode (mode) –
Keyword Arguments:
 

{int} -- current backlog (default (backlog) – {128})

Returns:

Socket obj – the current socket

static can_send()

Basic info wether service can send back or not

Returns:bool – can send back?
close()

Basic close service

static get_service(_params, _server=None)

Gets a service from service params EXAMPLE: _params[‘active_service’].append({

# tcp service “id”: 2, “antano_server_id”: 1, # needs to be the same as id above “service_type_id”: 2, “port”: 18002, “host”: “0.0.0.0”, “endpoint”: “”, # in case of rest or websocket /my_endpoint put “my_endpoint” “message_format_in_id”: 1, # message_format “message_format_out_id”: 1, # message_format

})

Parameters:{Dict<String, Obj>} -- service param (_params) –
Returns:Service obj – a service
get_ws_with_id(_id, _room)

Helper function for getting a ws from id

Parameters:
  • {Int} -- current client id (_id) –
  • {String} -- current room (_room) –
Returns:

WebSocket obj – ws or None

make(endpoint)

make app - creates a tornado endpoint with a given class

Parameters:{string} -- defined endpoints (endpoint) –
Returns:obj – web endpoint application
make_room(endpoint)

make app - creates a tornado endpoint with a given class

Parameters:{string} -- defined endpoints (endpoint) –
Returns:obj – web endpoint application
on_received_message(message, address, sock_stream)

On received message will process the message and if there is a repsonse it will send back to the same stream the client has send

Parameters:
  • {bytes[]} -- message data (message) –
  • {Tuple (address) –
  • {mixed} -- Socket or SOCK_STREAM (sock) –
Returns:

[bytes[]] – response

static run_processes(_services, _num_of_process)

Finally runs all processes for given sockets this is mandatory for creating port bindings after creating sub-processes

Parameters:
  • {array} -- array of services (_services) –
  • {int} -- number of processes to start (_num_of_process) –
send_message(message, address, stream, is_binary=False)

Basic send message from service

Parameters:
  • {bytes[]} -- message data (message) –
  • {Tuple (address) –
  • {mixed} -- Socket or SOCK_STREAM (sock) –
start(_params, _internal=False)

basic start function

Parameters:
  • {string} -- ip or host (_ip) –
  • {int} -- defined port (_port) –
stop()

Stops a service immediately

Last update: 10/08/2020 3:43 a.m. (CET)