Software /
code /
prosody
Changeset
5279:e8f7962056f5
net.server_select: Add pause and resume methods
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 28 Dec 2012 14:33:27 +0100 |
parents | 5278:f79be67e5666 |
children | 5280:1514a6147e85 |
files | net/server_select.lua |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_select.lua Fri Dec 28 14:32:22 2012 +0100 +++ b/net/server_select.lua Fri Dec 28 14:33:27 2012 +0100 @@ -197,6 +197,25 @@ --mem_free( ) out_put "server.lua: closed server handler and removed sockets from list" end + handler.pause = function() + if not handler.paused then + socket:close( ) + _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) + _readlistlen = removesocket( _readlist, socket, _readlistlen ) + _socketlist[ socket ] = nil + socket = nil; + handler.paused = true; + end + end + handler.resume = function() + if handler.paused then + socket = socket_bind( ip, serverport ); + socket:settimeout( 0 ) + _readlistlen = addsocket(_readlist, socket, _readlistlen) + _socketlist[ socket ] = handler + handler.paused = false; + end + end handler.ip = function( ) return ip end