@@ -284,35 +284,6 @@ function skynet.wait()
284
284
session_id_coroutine [session ] = nil
285
285
end
286
286
287
- local function globalname (name , handle )
288
- local c = string.sub (name ,1 ,1 )
289
- assert (c ~= ' :' )
290
- if c == ' .' then
291
- return false
292
- end
293
-
294
- assert (# name <= 16 ) -- GLOBALNAME_LENGTH is 16, defined in skynet_harbor.h
295
- assert (tonumber (name ) == nil ) -- global name can't be number
296
-
297
- local harbor = require " skynet.harbor"
298
-
299
- harbor .globalname (name , handle )
300
-
301
- return true
302
- end
303
-
304
- function skynet .register (name )
305
- if not globalname (name ) then
306
- c .command (" REG" , name )
307
- end
308
- end
309
-
310
- function skynet .name (name , handle )
311
- if not globalname (name , handle ) then
312
- c .command (" NAME" , name .. " " .. skynet .address (handle ))
313
- end
314
- end
315
-
316
287
local self_handle
317
288
function skynet .self ()
318
289
if self_handle then
@@ -329,13 +300,6 @@ function skynet.localname(name)
329
300
end
330
301
end
331
302
332
- function skynet .launch (...)
333
- local addr = c .command (" LAUNCH" , table.concat ({... }," " ))
334
- if addr then
335
- return string_to_handle (addr )
336
- end
337
- end
338
-
339
303
function skynet .now ()
340
304
return tonumber (c .command (" NOW" ))
341
305
end
@@ -374,14 +338,6 @@ function skynet.exit()
374
338
coroutine_yield " QUIT"
375
339
end
376
340
377
- function skynet .kill (name )
378
- if type (name ) == " number" then
379
- skynet .send (" .launcher" ," lua" ," REMOVE" ,name , true )
380
- name = skynet .address (name )
381
- end
382
- c .command (" KILL" ,name )
383
- end
384
-
385
341
function skynet .getenv (key )
386
342
local ret = c .command (" GETENV" ,key )
387
343
if ret == " " then
@@ -528,7 +484,7 @@ local function raw_dispatch_message(prototype, msg, sz, session, source, ...)
528
484
end
529
485
end
530
486
531
- local function dispatch_message (...)
487
+ function skynet . dispatch_message (...)
532
488
local succ , err = pcall (raw_dispatch_message ,... )
533
489
while true do
534
490
local key ,co = next (fork_queue )
@@ -650,7 +606,7 @@ function skynet.pcall(start)
650
606
return xpcall (init_template , debug.traceback , start )
651
607
end
652
608
653
- local function init_service (start )
609
+ function skynet . init_service (start )
654
610
local ok , err = skynet .pcall (start )
655
611
if not ok then
656
612
skynet .error (" init service failed: " .. tostring (err ))
@@ -662,56 +618,16 @@ local function init_service(start)
662
618
end
663
619
664
620
function skynet .start (start_func )
665
- c .callback (dispatch_message )
666
- skynet .timeout (0 , function ()
667
- init_service (start_func )
668
- end )
669
- end
670
-
671
- function skynet .filter (f ,start_func )
672
- c .callback (function (...)
673
- dispatch_message (f (... ))
674
- end )
621
+ c .callback (skynet .dispatch_message )
675
622
skynet .timeout (0 , function ()
676
- init_service (start_func )
677
- end )
678
- end
679
-
680
- function skynet .forward_type (map , start_func )
681
- c .callback (function (ptype , msg , sz , ...)
682
- local prototype = map [ptype ]
683
- if prototype then
684
- dispatch_message (prototype , msg , sz , ... )
685
- else
686
- dispatch_message (ptype , msg , sz , ... )
687
- c .trash (msg , sz )
688
- end
689
- end , true )
690
- skynet .timeout (0 , function ()
691
- init_service (start_func )
623
+ skynet .init_service (start_func )
692
624
end )
693
625
end
694
626
695
627
function skynet .endless ()
696
628
return c .command (" ENDLESS" )~= nil
697
629
end
698
630
699
- function skynet .abort ()
700
- c .command (" ABORT" )
701
- end
702
-
703
- function skynet .monitor (service , query )
704
- local monitor
705
- if query then
706
- monitor = skynet .queryservice (true , service )
707
- else
708
- monitor = skynet .uniqueservice (true , service )
709
- end
710
- assert (monitor , " Monitor launch failed" )
711
- c .command (" MONITOR" , string.format (" :%08x" , monitor ))
712
- return monitor
713
- end
714
-
715
631
function skynet .mqlen ()
716
632
return tonumber (c .command " MQLEN" )
717
633
end
738
654
-- Inject internal debug framework
739
655
local debug = require " skynet.debug"
740
656
debug (skynet , {
741
- dispatch = dispatch_message ,
657
+ dispatch = skynet . dispatch_message ,
742
658
clear = clear_pool ,
743
659
suspend = suspend ,
744
660
})
0 commit comments