Posted on Thursday, September 22, 2011Written by Michael Colon

Basic Line Receiver
from twisted.internet import protocol, reactor
from twisted.protocols import basic
class LineProtocol(basic.LineReceiver):
def lineReceived(self, line):
self.transport.write('You sent me this: '+line)
self.transport.loseConnection()
class LineFactory(protocol.ServerFactory):
protocol = LineProtocol
reactor.listenTCP(8001), LineFactory())
reactor.run()
Read full article here >>
Posted in Python
Posted on Thursday, September 22, 2011Written by Michael Colon

Interface Of The Protocol Class
While investigating the possible uses for the Twisted Networking Engine, I found it hard to find examples that describe the Interface of the Protocol class. So, I will share this brief code snippet with you.
Protocol Class
A Protocol class can have the following methods for event-driven TCP connections:
MyProtocol(Protocol):
def makeConnection(self, transport):
''' code '''
def connectionMade(self):
''' code '''
def dataReceived(self, data):
'''' code ''''
def connectionLost(self, reason):
''' code '''
Read full article here >>
Posted in Code, Python
Posted on Thursday, September 22, 2011Written by Michael Colon

Node.js is a server-side JavaScript framework used for developing event-driven networking programs for concurrency rather then threading.
var net = require('net');
port = 8001;
net.createServer(function (stream) {
stream.setEncoding('utf8');
stream.on('connect', function () {
stream.write('hi, Your connected to my TCP Server!');
});
stream.on('data', function (data) {
stream.write('Writing network data..');
});
stream.on('end', function () {
stream.write("bye bye");
stream.end();
});
}).listen(port, "localhost");
console.log("Server started at port "+port);
Read full article here >>
Posted in Code, Node.js
Posted on Thursday, September 22, 2011Written by Michael Colon

Multiple Choice
Out of the following three code snippets, only one is optimized. Which snippet is it?
Snippet 1
for (object in objects) {
if ( [object tag] == kTagObjectOne ) {
[object foo];
}
[object bar];
}
Snippet 2
for (object in objects) {
if ( [object tag] == kTagObjectOne ) {
[object foo];
[object bar];
} else {
[object bar];
}
}
Snippet 3
for (object in objects) {
if ([object tag] != kTagObjectOne )
[object bar];
}
object = [objects getChildByTag:kTagObjectOne];
if (object) {
[object foo];
[object bar];
}
Read full article here >>
Posted in Code, Objective-C
Posted on Thursday, September 22, 2011Written by Michael Colon

Interestingly enough, I found that the SneakyInput registers a button tap twice or more in tests. This seems to be attributed to a very quick frame rate.
I have a frame rate that stays between 60 and 58. So, while my finger is pressed on a jump or fire button the game has cycled through a couple frames.
Read full article here >>
Posted in Cocos2d, Code, Objective-C