Software /
code /
prosody
Comparison
net/server_event.lua @ 4984:724848dfde36
net.server_event: Remove unused variables and imports
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 22 Jul 2012 23:45:53 +0100 |
parent | 4962:1d8fb12a9b2d |
child | 5010:2f8f388de516 |
comparison
equal
deleted
inserted
replaced
4983:4fd6a020d0d8 | 4984:724848dfde36 |
---|---|
31 CLEAR_DELAY = 5, -- seconds to wait for clearing interface list (and calling ondisconnect listeners) | 31 CLEAR_DELAY = 5, -- seconds to wait for clearing interface list (and calling ondisconnect listeners) |
32 DEBUG = true, -- show debug messages | 32 DEBUG = true, -- show debug messages |
33 } | 33 } |
34 | 34 |
35 local function use(x) return rawget(_G, x); end | 35 local function use(x) return rawget(_G, x); end |
36 local print = use "print" | |
37 local pcall = use "pcall" | |
38 local ipairs = use "ipairs" | 36 local ipairs = use "ipairs" |
39 local string = use "string" | 37 local string = use "string" |
40 local select = use "select" | 38 local select = use "select" |
41 local require = use "require" | 39 local require = use "require" |
42 local tostring = use "tostring" | 40 local tostring = use "tostring" |
210 _, err = self.conn:dohandshake( ) | 208 _, err = self.conn:dohandshake( ) |
211 if not err then | 209 if not err then |
212 self:_lock( false, false, false ) -- unlock the interface; sending, closing etc allowed | 210 self:_lock( false, false, false ) -- unlock the interface; sending, closing etc allowed |
213 self.send = self.conn.send -- caching table lookups with new client object | 211 self.send = self.conn.send -- caching table lookups with new client object |
214 self.receive = self.conn.receive | 212 self.receive = self.conn.receive |
215 local onsomething | |
216 if not call_onconnect then -- trigger listener | 213 if not call_onconnect then -- trigger listener |
217 self:onstatus("ssl-handshake-complete"); | 214 self:onstatus("ssl-handshake-complete"); |
218 end | 215 end |
219 self:_start_session( call_onconnect ) | 216 self:_start_session( call_onconnect ) |
220 debug( "ssl handshake done" ) | 217 debug( "ssl handshake done" ) |
468 local handleclient; | 465 local handleclient; |
469 do | 466 do |
470 local string_sub = string.sub -- caching table lookups | 467 local string_sub = string.sub -- caching table lookups |
471 local string_len = string.len | 468 local string_len = string.len |
472 local addevent = base.addevent | 469 local addevent = base.addevent |
473 local coroutine_wrap = coroutine.wrap | |
474 local socket_gettime = socket.gettime | 470 local socket_gettime = socket.gettime |
475 local coroutine_yield = coroutine.yield | |
476 function handleclient( client, ip, port, server, pattern, listener, sslctx ) -- creates an client interface | 471 function handleclient( client, ip, port, server, pattern, listener, sslctx ) -- creates an client interface |
477 --vdebug("creating client interfacce...") | 472 --vdebug("creating client interfacce...") |
478 local interface = { | 473 local interface = { |
479 type = "client"; | 474 type = "client"; |
480 conn = client; | 475 conn = client; |
740 end | 735 end |
741 end )( ) | 736 end )( ) |
742 | 737 |
743 local addclient, wrapclient | 738 local addclient, wrapclient |
744 do | 739 do |
745 function wrapclient( client, ip, port, listeners, pattern, sslctx, startssl ) | 740 function wrapclient( client, ip, port, listeners, pattern, sslctx ) |
746 local interface = handleclient( client, ip, port, nil, pattern, listeners, sslctx ) | 741 local interface = handleclient( client, ip, port, nil, pattern, listeners, sslctx ) |
747 interface:_start_connection(sslctx) | 742 interface:_start_connection(sslctx) |
748 return interface, client | 743 return interface, client |
749 --function handleclient( client, ip, port, server, pattern, listener, _, sslctx ) -- creates an client interface | 744 --function handleclient( client, ip, port, server, pattern, listener, _, sslctx ) -- creates an client interface |
750 end | 745 end |
776 end | 771 end |
777 end | 772 end |
778 local res, err = client:connect( addr, serverport ) -- connect | 773 local res, err = client:connect( addr, serverport ) -- connect |
779 if res or ( err == "timeout" ) then | 774 if res or ( err == "timeout" ) then |
780 local ip, port = client:getsockname( ) | 775 local ip, port = client:getsockname( ) |
781 local server = function( ) | |
782 return nil, "this is a dummy server interface" | |
783 end | |
784 local interface = wrapclient( client, ip, serverport, listener, pattern, sslctx, startssl ) | 776 local interface = wrapclient( client, ip, serverport, listener, pattern, sslctx, startssl ) |
785 interface:_start_connection( startssl ) | 777 interface:_start_connection( startssl ) |
786 debug( "new connection id:", interface.id ) | 778 debug( "new connection id:", interface.id ) |
787 return interface, err | 779 return interface, err |
788 else | 780 else |