bbc1.core.user_message_routing module — BBc1 1.2 documentation

# bbc1.core.user_message_routing module

Copyright (c) 2017 beyond-blockchain.org.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

> http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class `bbc1.core.user_message_routing.` `UserMessageRouting`(networking, domain_id, loglevel='all', logname=None)

  Bases: `object`

  Handle message for clients

  `CROSS_REF_ASSIGNMENT` = b'\x00\x05'
  `JOIN_MULTICAST_RECEIVER` = b'\x00\x03'
  `LEAVE_MULTICAST_RECEIVER` = b'\x00\x04'
  `MAX_CROSS_REF_STOCK` = 10
  `REFRESH_FORWARDING_LIST_INTERVAL` = 300
  `RESOLVE_TIMEOUT` = 5
  `RESOLVE_USER_LOCATION` = b'\x00\x00'
  `RESPONSE_NO_SUCH_USER` = b'\x00\x02'
  `RESPONSE_USER_LOCATION` = b'\x00\x01'
  `process_message`(msg)

    Process received message

    Parameters: | msg (dict) – received message

  `register_user`(user_id, socket, on_multiple_nodes=False)

    Register user to forward message

    Parameters: | user_id (bytes) – user_id of the client socket (Socket) – socket for the client on_multiple_nodes (bool) – If True, the user_id is also registered in other nodes, meaning multicasting.

  `send_message_to_user`(msg, direct_only=False)

    Forward message to connecting user

    Parameters: | msg (dict) – message to send direct_only (bool) – If True, _forward_message_to_another_node is not called.

  `send_multicast_join`(user_id, permanent=False)

    Broadcast JOIN_MULTICAST_RECEIVER

  `send_multicast_leave`(user_id)

    Broadcast LEAVE_MULTICAST_RECEIVER

  `set_aes_name`(socket, name)

    Set name for specifying AES key for message encryption

    Parameters: | socket (Socket) – socket for the client name (bytes) – name of the client (4-byte random value generated in message_key_types.get_ECDH_parameters)

  `stop_all_timers`()

    Cancel all running timers

  `unregister_user`(user_id, socket)

    Unregister user from the list and delete AES key if exists

    Parameters: | user_id (bytes) – user_id of the client socket (Socket) – socket for the client

class `bbc1.core.user_message_routing.` `UserMessageRoutingDummy`(networking, domain_id, loglevel='all', logname=None)

  Bases: `bbc1.core.user_message_routing.UserMessageRouting`

  Dummy class for bbc_core.py

  `process_message`(msg)

    Process received message

    Parameters: | msg (dict) – received message

  `register_user`(user_id, socket, on_multiple_nodes=False)

    Register user to forward message

    Parameters: | user_id (bytes) – user_id of the client socket (Socket) – socket for the client on_multiple_nodes (bool) – If True, the user_id is also registered in other nodes, meaning multicasting.

  `send_message_to_user`(msg, direct_only=False)

    Forward message to connecting user

    Parameters: | msg (dict) – message to send direct_only (bool) – If True, _forward_message_to_another_node is not called.

  `send_multicast_join`(user_id, permanent=False)

    Broadcast JOIN_MULTICAST_RECEIVER

  `stop_all_timers`()

    Cancel all running timers

  `unregister_user`(user_id, socket=None)

    Unregister user from the list and delete AES key if exists

    Parameters: | user_id (bytes) – user_id of the client socket (Socket) – socket for the client

`bbc1.core.user_message_routing.` `direct_send_to_user`(sock, msg, name=None)