/simulatie/connection.py (8acadb21da26aed6eeb7c3a4db390d29108f6901) (1160 bytes) (mode 100644) (type blob)
import pika
import threading
import model
import pyg
creds = pika.PlainCredentials(model.uname, model.passwd)
SendConnection = pika.BlockingConnection(pika.ConnectionParameters(host=model.host, virtual_host=model.vhost, credentials=creds))
RecieveConnection = pika.BlockingConnection(pika.ConnectionParameters(host=model.host, virtual_host=model.vhost, credentials=creds))
channel = SendConnection.channel()
recieve = RecieveConnection.channel()
recieve.queue_declare(
queue=model.recieveQueue,
arguments={'x-message-ttl' : 10000},
auto_delete=True
)
def callback(ch, method, prop, body):
print(model.recieveQueue + ': ')
print(body.decode('utf-8', 'ignore'))
def sendMsg(msg):
channel.basic_publish (
exchange='',
routing_key=model.sendQueue,
body=msg
)
print('Msg sent.')
def listen():
print('Waiting for a sign..')
recieve.basic_consume (
callback,
queue=model.recieveQueue,
no_ack=True
)
recieve.start_consuming()
thread = threading.Thread(target=listen)
thread.setDaemon(True)
thread.start()
thread.join(0)
gamethread = threading.Thread(target=pyg.gameloop)
gamethread.setDaemon(True)
gamethread.start()
gamethread.join(0)
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
16 |
c6829d54ec4540d0a7ad29f662a2c128e0da945c |
.gitignore |
040000 |
tree |
- |
f4d3a07b7699a8e327f9a2e932383f4a1275f7df |
Controller |
100644 |
blob |
565 |
39af52c077c0d4c3bc7730b362592e0bf7f635db |
README.md |
040000 |
tree |
- |
5b8609673ae5fd48f5f802caa4b13e426c72a644 |
jar |
040000 |
tree |
- |
e1fc63bf64e8aed2ba3b27f543e337b20bf6ca91 |
simulatie |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/NHL-SoftDev
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/NHL-SoftDev
Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/NHL-SoftDev
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main