root/version_0/ext2/eventmachine_cpp.h

Revision 635, 2.1 kB (checked in by blackhedd, 1 year ago)

temporary branch to hold some code that isn't ready for prime time yet.
This will be deleted when no longer needed.

Line 
1 /*****************************************************************************
2
3 $Id: eventmachine_cpp.h 474 2007-07-27 03:12:30Z blackhedd $
4
5 File:     eventmachine_cpp.h
6 Date:     27Jul07
7
8 Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9 Gmail: blackhedd
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either: 1) the GNU General Public License
13 as published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version; or 2) Ruby's License.
15
16 See the file COPYING for complete licensing information.
17
18 *****************************************************************************/
19
20
21 #ifndef __EVMA_EventmachineCpp__H_
22 #define __EVMA_EventmachineCpp__H_
23
24
25 // This material is only for directly integrating EM into C++ programs.
26
27 namespace EM {
28
29         void Callback (const char *sig, int event, const char *data, int length);
30         void Run (void(*)(void));
31         void AddTimer (int, void(*)());
32         void StopReactor();
33
34         /***************
35         class Eventable
36         ***************/
37
38         class Eventable {
39                 public:
40                         Eventable() {}
41                         virtual ~Eventable() {}
42
43                         std::string Signature;
44
45                         // Called by the framework
46                         virtual void ReceiveData (const char *data, int length) {}
47                         virtual void ConnectionCompleted() {}
48                         virtual void Accept (const char*) {}
49                         virtual void Unbind() {}
50                         virtual void PostInit() {}
51
52                         void StopReactor() {EM::StopReactor();}
53         };
54
55         /****************
56         class Connection
57         ****************/
58
59         class Connection: public Eventable {
60                 public:
61                         Connection() {}
62                         virtual ~Connection() {}
63
64                         virtual void Connect (const char*, int);
65
66                         void SendData (const char *data);
67                         void SendData (const char *data, int length);
68                         void Close (bool afterWriting);
69         };
70
71
72         /**************
73         class Acceptor
74         **************/
75
76         class Acceptor: public Eventable {
77                 public:
78                         Acceptor() {PostInit();}
79                         virtual ~Acceptor() {}
80
81                         void Start (const char*, int);
82                         void Accept (const char*);
83
84                         virtual Connection *MakeConnection() {return new Connection();}
85         };
86
87
88 };
89
90
91
92
93
94 #endif // __EVMA_EventmachineCpp__H_
Note: See TracBrowser for help on using the browser.