Example #1
1
 def connect(self,f=''):
     '''
     Connect to server using self.flags (or default)
     '''
     #TODO configurations
     
     if(self.flags==''):
         self.flags= pyinsim.ISF_CON|pyinsim.ISF_MCI #contact
     print 'Connecting to '+str(self.ip), "flags ",self.flags
     self.insim = pyinsim.insim(self.ip, self.port, Admin=self.passw,Flags=self.flags,Interval=self.interval)
     
     #TODO flag to enable, disable outgauge
     if(self.outg_enabled):
         print "Initializing outgauge port: ",self.outgauge_port, " int: ",self.outgauge_interval
         self.outgauge = pyinsim.outgauge('127.0.0.1', self.outgauge_port, self.outgauge_packet, self.outgauge_interval)
     
     if(self.outs_enabled):
         print "Initializing Outsim port: ",self.outsim_port, " int: ",self.outsim_interval
         self.outsim= pyinsim.outsim('127.0.0.1', self.outsim_port, self.outsim_packet, self.outsim_interval)
     
     self.__bindEvents()
     #self.run()
     
     #we need to request connections and players 
     self.request_connection_list()
     self.request_player_list()
     self.sendMsg(self.tag +' V.'+ str(self.version)+ " started.")
Example #2
0
    def connect(self, f=''):
        '''
        Connect to server using self.flags (or default)
        '''
        #TODO configurations

        if (self.flags == ''):
            self.flags = pyinsim.ISF_CON | pyinsim.ISF_MCI  #contact
        print 'Connecting to ' + str(self.ip), "flags ", self.flags
        self.insim = pyinsim.insim(self.ip,
                                   self.port,
                                   Admin=self.passw,
                                   Flags=self.flags,
                                   Interval=self.interval)

        #TODO flag to enable, disable outgauge
        if (self.outg_enabled):
            print "Initializing outgauge port: ", self.outgauge_port, " int: ", self.outgauge_interval
            self.outgauge = pyinsim.outgauge('127.0.0.1', self.outgauge_port,
                                             self.outgauge_packet,
                                             self.outgauge_interval)

        if (self.outs_enabled):
            print "Initializing Outsim port: ", self.outsim_port, " int: ", self.outsim_interval
            self.outsim = pyinsim.outsim('127.0.0.1', self.outsim_port,
                                         self.outsim_packet,
                                         self.outsim_interval)

        self.__bindEvents()
        #self.run()

        #we need to request connections and players
        self.request_connection_list()
        self.request_player_list()
        self.sendMsg(self.tag + ' V.' + str(self.version) + " started.")
Example #3
0
def outgauge_init():
    global insim
    while (running):
        insim = pyinsim.insim('192.168.1.10', 29999, Admin='')
        insim.bind(pyinsim.EVT_ALL, all)
        outsim = pyinsim.outsim('0.0.0.0', 10000, outsim_packet, 2.0)
        outgauge = pyinsim.outgauge('0.0.0.0', 10001, outgauge_packet, 2.0)

        pyinsim.run()
        print "Connection Closed, Retrying"
Example #4
0
                         packet.Vel[0], packet.Vel[1], packet.Vel[2],
                         packet.Pos[0], packet.Pos[1], packet.Pos[2])


def outsim_handler(outsim, packet):
    if(outSocket != None):
        for a in addrs:
            outSocket.sendto(pack_outsimpacket(packet), (a[0], a[1]));



if __name__ == '__main__':
    parser = OptionParser();
    parser.add_option("--outsim-port", action="store", type="int", dest="outsimPort", default=13338);
    parser.add_option("--remote-host", action="store", type="str", dest="remote_host", default="127.0.0.1");
    parser.add_option("--remote-port", action="store", type="int", dest="remote_port", default=13336);

    (options, args) = parser.parse_args();

    # Lägg till remote host
    addrs.append((options.remote_host, options.remote_port));
    
    outsimPort = options.outsimPort;
    outSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM);
    pyinsim.outsim('127.0.0.1', outsimPort, outsim_handler, 30.0);
    while(True):
        pyinsim.run(False);
        # Insim fick timeout, vi försöker igen
        print "Insim timeout, retrying...";