Software /
code /
prosody
Comparison
net/server_select.lua @ 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 |
parent | 5197:beffe931b3b6 |
child | 5280:1514a6147e85 |
comparison
equal
deleted
inserted
replaced
5278:f79be67e5666 | 5279:e8f7962056f5 |
---|---|
194 _socketlist[ socket ] = nil | 194 _socketlist[ socket ] = nil |
195 handler = nil | 195 handler = nil |
196 socket = nil | 196 socket = nil |
197 --mem_free( ) | 197 --mem_free( ) |
198 out_put "server.lua: closed server handler and removed sockets from list" | 198 out_put "server.lua: closed server handler and removed sockets from list" |
199 end | |
200 handler.pause = function() | |
201 if not handler.paused then | |
202 socket:close( ) | |
203 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) | |
204 _readlistlen = removesocket( _readlist, socket, _readlistlen ) | |
205 _socketlist[ socket ] = nil | |
206 socket = nil; | |
207 handler.paused = true; | |
208 end | |
209 end | |
210 handler.resume = function() | |
211 if handler.paused then | |
212 socket = socket_bind( ip, serverport ); | |
213 socket:settimeout( 0 ) | |
214 _readlistlen = addsocket(_readlist, socket, _readlistlen) | |
215 _socketlist[ socket ] = handler | |
216 handler.paused = false; | |
217 end | |
199 end | 218 end |
200 handler.ip = function( ) | 219 handler.ip = function( ) |
201 return ip | 220 return ip |
202 end | 221 end |
203 handler.serverport = function( ) | 222 handler.serverport = function( ) |