I'm pretty much a beginner in Python. I'm having a project to create a UDP chat in Python. I want to resolve an issue of creating an Online message. I typed the code but it is giving error.
#! /usr/bin/env python
#coding:utf-8
from twisted.internet.task import LoopingCall
from twisted.internet import reactor
from twisted.internet.protocol import DatagramProtocol
def mensagem_presenca():
print("Estou Online!!")
class Client(DatagramProtocol):
def sendMessage(self, data, host, port):
self.transport.write(data, host, port)
lc = LoopingCall(sendMessage("teste", localhost, 8888))
lc.start(30.0)
reactor.run()
luiz @ luiz: ~ $ python teste_timer.py Traceback (most recent call last): File "test_timer.py", line 16, in lc = LoopingCall (sendMessage ("test", localhost, 8888)) NameError: name 'sendMessage' is not defined luiz @ luiz: ~ $
What can it be?