Merge branch 'master' of cybre.tech:chr/matrix-appservice-minecraft
This commit is contained in:
commit
dd0ff125a7
|
@ -121,8 +121,8 @@ class socket_util(object):
|
||||||
|
|
||||||
class MinecraftWrapper(socket_util):
|
class MinecraftWrapper(socket_util):
|
||||||
def __init__(self, command, host, port):
|
def __init__(self, command, host, port):
|
||||||
super().__init__(host, port)
|
|
||||||
self.logger = LOG.getChild("MinecraftWrapper")
|
self.logger = LOG.getChild("MinecraftWrapper")
|
||||||
|
super().__init__(host, port)
|
||||||
self.logger.debug(command)
|
self.logger.debug(command)
|
||||||
self.command = command
|
self.command = command
|
||||||
self.logger.info("Starting Wrapper Polling Thread")
|
self.logger.info("Starting Wrapper Polling Thread")
|
||||||
|
@ -134,7 +134,22 @@ class MinecraftWrapper(socket_util):
|
||||||
def socket_reset(self):
|
def socket_reset(self):
|
||||||
super().socket_reset()
|
super().socket_reset()
|
||||||
self.logger.debug("Connecting to {}:{}".format(self.host, self.port))
|
self.logger.debug("Connecting to {}:{}".format(self.host, self.port))
|
||||||
self.soc.connect((self.host, self.port))
|
backoff = 1
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
self.soc.connect((self.host, self.port))
|
||||||
|
break
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno == 111:
|
||||||
|
LOG.warning(
|
||||||
|
"Connection refused by {}:{}, trying again in {} seconds".format(
|
||||||
|
self.host, self.port, backoff
|
||||||
|
)
|
||||||
|
)
|
||||||
|
time.sleep(backoff)
|
||||||
|
backoff *= 2
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
self.logger.info("Socket Connected")
|
self.logger.info("Socket Connected")
|
||||||
|
|
||||||
def exe_mc(self):
|
def exe_mc(self):
|
||||||
|
@ -216,8 +231,8 @@ class MinecraftServerBridge(socket_util):
|
||||||
def socket_reset(self):
|
def socket_reset(self):
|
||||||
super().socket_reset()
|
super().socket_reset()
|
||||||
LOG.info("Server Binding to " + self.host + " " + str(self.port))
|
LOG.info("Server Binding to " + self.host + " " + str(self.port))
|
||||||
|
backoff = 1
|
||||||
while True:
|
while True:
|
||||||
backoff = 1
|
|
||||||
try:
|
try:
|
||||||
self.soc.bind((self.host, self.port))
|
self.soc.bind((self.host, self.port))
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue