# -*- coding: utf-8 -*-
import sys
sys.path.insert(0, '../../')

from maple import Trigger
from maple import constants
import time
from netkit.box import Box

import logging

logger = logging.getLogger('maple')
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)


def main():
    # trigger = Trigger(Box, '192.168.1.67', 28000)
    trigger = Trigger(Box, '115.28.224.64', 28000)

    for it in xrange(0, 99999):
        time.sleep(1)

        # print trigger.write_to_worker(dict(
        #     cmd=3,
        #     ret=100,
        #     body='from trigger: %s' % it
        # ))
        # print trigger.close_users([constants.CONNS_AUTHED], 0)
        # print trigger.close_users([constants.CONNS_ALL], 1)
        print trigger.write_to_users([
            ([constants.CONNS_AUTHED], dict(cmd=1, body='direct event from trigger: %s' % it), 0)
        ])


main()
