Git Repository Public Repository

namibia

URLs

Copy to Clipboard
 
1074a2d61ec9d93a0ac7e0181875a2202b1225c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php

#-> Root ourselves.
chdir(dirname(__DIR__));
date_default_timezone_set('Africa/Johannesburg');

#-> Bootstrap.
require_once 'init_autoloader.php';


#-> Our primary workspace for getting stuff done.
class Workspace
{

	/**
	 * @var \React\ZMQ\SocketWrapper
	 */
	static private $mqClient;


	/**
	 * Initialize.
	 */
	static public function init()
	{
		self::$mqClient = (new \ZMQContext())->getSocket(\ZMQ::SOCKET_PUSH, 'WebsocketWorkerPublisher');
		self::$mqClient->connect("tcp://127.0.0.1:90");
	}

	/**
	 * Send broadcast request to socket server.
	 * @param  GearmanJob $job
	 * @return null
	 */
	static public function broadcast(GearmanJob $job)
	{
		#-> Instruct socket server to do a broadcast.
		self::$mqClient->send($job->workload());
	}


}



#-> Get up and running.
Workspace::init();

#-> Register as a gearman worker.
$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction('Broadcast', array('Workspace', 'broadcast'));

#-> Wait for jobs to come in.
while ($worker->work())
{
	;
}

Commits for namibia/workers/Workspace.php

Diff revisions: vs.
Revision Author Commited Message
df0489 ... Mark Fri 14 Oct, 2016 10:01:00 +0000

initial commit