Beispiel #1
0
#coding:utf8
'''
Created on 2013-8-14

@author: lan
'''
from firefly.server.globalobject import GlobalObject
from firefly.netconnect.datapack import DataPackProtoc


def callWhenConnLost(conn):
    dynamicId = conn.transport.sessionno
    GlobalObject().remote['gate'].callRemote("netconnlost", dynamicId)


GlobalObject().netfactory.doConnectionLost = callWhenConnLost
dataprotocl = DataPackProtoc(19, 82, 8, 28, 1, 1)
GlobalObject().netfactory.setDataProtocl(dataprotocl)


def loadModule():
    import netapp
    import gatenodeapp
Beispiel #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2015/5/8
@author: Linwencai
"""
from firefly.server.globalobject import GlobalObject
from firefly.netconnect.datapack import DataPackProtoc

# 定义包头
dataprotocl = DataPackProtoc(1, 2, 3, 4, 5, 6)
GlobalObject().netfactory.setDataProtocl(dataprotocl)


def callWhenConnCreate(conn):
    """ 连接建立时回调
    """
    return


GlobalObject().netfactory.doConnectionMade = callWhenConnCreate


def callWhenConnLost(conn):
    """ 连接断开时回调
    """
    dynamicId = conn.transport.sessionno
    GlobalObject().remote['gate'].callRemote("netconnlost", dynamicId)
    return

Beispiel #3
0
#coding:utf8
'''
Created on 2013-8-14

@author: lan (www.9miao.com)
'''
from firefly.server.globalobject import GlobalObject
from firefly.netconnect.datapack import DataPackProtoc


def doConnectionMade(conn):
    str3 = '<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\"/></cross-domain-policy>'
    GlobalObject().netfactory.pushObject(11009, str3,
                                         [conn.transport.sessionno])


def callWhenConnLost(conn):
    dynamicId = conn.transport.sessionno
    GlobalObject().remote['gate'].callRemote("netconnlost", dynamicId)


GlobalObject().netfactory.doConnectionLost = callWhenConnLost
GlobalObject().netfactory.doConnectionMade = doConnectionMade
dataprotocl = DataPackProtoc(0, 0, 0, 0, 0, 0)
GlobalObject().netfactory.setDataProtocl(dataprotocl)


def loadModule():
    import netapp
    import gatenodeapp
Beispiel #4
0
def CreatVersionResult(netversion):
    from protoFile import getServerVersion_pb2
    response = getServerVersion_pb2.getVersionResponse()
    response.version = netversion
    msg = response.SerializeToString()
    return msg


def doConnectionMade(conn):
    '''当连接建立时调用的方法'''
    GlobalObject().netfactory.pushObject(
        10001, CreatVersionResult("Distributed Login Test"),
        [conn.transport.sessionno])


dataprotocl = DataPackProtoc(78, 37, 38, 48, 9, 0)  #协议头
GlobalObject().netfactory.setDataProtocl(dataprotocl)

GlobalObject().netfactory.doConnectionLost = callWhenConnLost
GlobalObject().netfactory.doConnectionMade = doConnectionMade
GlobalObject().remote['gate']._reference._service.unDisplay.add("pushData")
GlobalObject().remote['gate']._reference._service.unDisplay.add("pushObject")


def loadModule():
    #    from firefly.dbentrust.dbpool import dbpool
    #    from firefly.dbentrust.memclient import mclient
    #    dbconfig = dbpool.config
    #    dbaccess.dbpool.initPool(**dbconfig)
    #    dbaccess.memclient = mclient
    #    dbaccess.memdb = mclient.connection
 def __init__(self, port, dataprotocl=DataPackProtoc()):
     WebSocketServerFactory.__init__(self, url="ws://127.0.0.1:%s" % port)
     self.service = None
     self.connmanager = ConnectionManager()
     self.dataprotocl = dataprotocl