| 930 | | private |
|---|
| 931 | | def EventMachine::event_callback conn_binding, opcode, data |
|---|
| 932 | | case opcode |
|---|
| 933 | | when ConnectionData |
|---|
| 934 | | c = @conns[conn_binding] or raise ConnectionNotBound |
|---|
| 935 | | c.receive_data data |
|---|
| 936 | | when ConnectionUnbound |
|---|
| 937 | | if c = @conns.delete( conn_binding ) |
|---|
| 938 | | c.unbind |
|---|
| 939 | | elsif c = @acceptors.delete( conn_binding ) |
|---|
| 940 | | # no-op |
|---|
| 941 | | else |
|---|
| 942 | | raise ConnectionNotBound |
|---|
| 943 | | end |
|---|
| 944 | | when ConnectionAccepted |
|---|
| 945 | | accep,blk = @acceptors[conn_binding] |
|---|
| 946 | | raise NoHandlerForAcceptedConnection unless accep |
|---|
| 947 | | c = accep.new data |
|---|
| 948 | | @conns[data] = c |
|---|
| 949 | | blk and blk.call(c) |
|---|
| 950 | | c # (needed?) |
|---|
| 951 | | when TimerFired |
|---|
| 952 | | t = @timers.delete( data ) or raise UnknownTimerFired |
|---|
| 953 | | t.call |
|---|
| 954 | | when ConnectionCompleted |
|---|
| 955 | | c = @conns[conn_binding] or raise ConnectionNotBound |
|---|
| 956 | | c.connection_completed |
|---|
| 957 | | when LoopbreakSignalled |
|---|
| 958 | | run_deferred_callbacks |
|---|
| 959 | | end |
|---|
| 960 | | end |
|---|
| | 930 | private |
|---|
| | 931 | def EventMachine::event_callback conn_binding, opcode, data |
|---|
| | 932 | if opcode == ConnectionData |
|---|
| | 933 | c = @conns[conn_binding] or raise ConnectionNotBound |
|---|
| | 934 | c.receive_data data |
|---|
| | 935 | elsif opcode == ConnectionUnbound |
|---|
| | 936 | if c = @conns.delete( conn_binding ) |
|---|
| | 937 | c.unbind |
|---|
| | 938 | elsif c = @acceptors.delete( conn_binding ) |
|---|
| | 939 | # no-op |
|---|
| | 940 | else |
|---|
| | 941 | raise ConnectionNotBound |
|---|
| | 942 | end |
|---|
| | 943 | elsif opcode == ConnectionAccepted |
|---|
| | 944 | accep,blk = @acceptors[conn_binding] |
|---|
| | 945 | raise NoHandlerForAcceptedConnection unless accep |
|---|
| | 946 | c = accep.new data |
|---|
| | 947 | @conns[data] = c |
|---|
| | 948 | blk and blk.call(c) |
|---|
| | 949 | c # (needed?) |
|---|
| | 950 | elsif opcode == TimerFired |
|---|
| | 951 | t = @timers.delete( data ) or raise UnknownTimerFired |
|---|
| | 952 | t.call |
|---|
| | 953 | elsif opcode == ConnectionCompleted |
|---|
| | 954 | c = @conns[conn_binding] or raise ConnectionNotBound |
|---|
| | 955 | c.connection_completed |
|---|
| | 956 | elsif opcode == LoopbreakSignalled |
|---|
| | 957 | run_deferred_callbacks |
|---|
| | 958 | end |
|---|
| | 959 | end |
|---|