Esempio n. 1
0
# -*- coding:utf-8 -*-
"""
Created on 19/06/2017

@author: zhaojm
"""

from frame.entity.base_server import BaseServer


class EchoServer(BaseServer):
    def __init__(self):
        BaseServer.__init__(self)
        pass

    def on_msg(self, conn, msg):
        print msg
        conn.sendLine(msg)


if __name__ == '__main__':
    from frame.core.reactor import start_reactor, init_server

    c = EchoServer()
    init_server(c, '0.0.0.0', 8888)
    start_reactor()
Esempio n. 2
0
# -*- coding:utf-8 -*-
"""
Created on 19/06/2017

@author: zhaojm
"""

import os
import sys

current_path = os.path.dirname(os.path.abspath(__file__))
source_path = os.path.join(current_path, "../../../")
sys.path.append(source_path)

from echo_server import EchoServer
from frame.core import reactor

if __name__ == '__main__':
    s = EchoServer()
    reactor.init_server(s, '0.0.0.0', 8888)
    reactor.start_reactor()
Esempio n. 3
0
# -*- coding:utf-8 -*-
"""
Created on 20/06/2017

@author: zhaojm
"""

from frame.core.entity import Entity


class BaseServer(Entity):
    def __init__(self):
        pass

    def on_conn_made(self, conn):
        pass

    def on_conn_lost(self, conn, reason):
        pass

    def on_msg(self, conn, msg):
        pass


if __name__ == '__main__':
    from frame.core.reactor import init_server, start_reactor

    s = BaseServer()
    init_server(s, '0.0.0.0', 8888)
    start_reactor()