Exemplo n.º 1
0
APIModVersion::APIModVersion(CharString versionstr){ // discards name split from ':', only keeps version number
    major = minor = submajor = subminor = 0;
    atleastver = false;
    
    // forget modname if it is still in the string
    if(versionstr.contains(":")){
        LinkedList<CharString> vsplit = versionstr.split(":");
        versionstr = vsplit[1];
    }
    
    this->versionstring = versionstr; // keep original string
    
    if(versionstr.startsWith(">")){
        atleastver = true;
        versionstr.shiftLeft(1);
    }
    
    if(versionstr.startsWith("v")) versionstr.shiftLeft(1);
    
    if(versionstr.contains(".")){
        LinkedList<CharString> vsplit = versionstr.split(".");
        if(vsplit[0].isValidNumber()) major = vsplit[0].getInt();
        if(vsplit[1].isValidNumber()) minor = vsplit[1].getInt();
        if(vsplit.size() >= 3 && vsplit[2].isValidNumber()) submajor = vsplit[2].getInt();
        if(vsplit.size() >= 4 && vsplit[3].isValidNumber()) subminor = vsplit[3].getInt();
    }else{
        // what? Single version number?
        if(versionstr.isValidNumber()){
            major = versionstr.getInt();
        }else{
            // dunno...
            cout << "API Mod Version could not figure out the version for " << versionstring << endl;
        }
    }
}
Exemplo n.º 2
0
void _msgClientHandler_ANY_recv(MSGServer *serv, MSGClient* cli, CharString dataIn, CharString &dataOut){
    // handles any message type.
    
    if(dataIn.startsWith("channel:publish:")){ // channel publish data (to here!)
        // channel:publish:CHANNAME:DATA
        LinkedList<CharString> c = dataIn.split(":");
        // +":id" when sent to other channels
        MSGClientChannel* chan = serv->getMSGChannel(c[2]);
        if(chan != 0x0){
            CharString pack = dataIn;
            pack += ":";
            pack += cli->identity;
            chan->distributemessagepacket(pack); // send out the goods
        }
        
    }else if(dataIn.startsWith("channel:subscribe:")){ // client subscribes to channel
        // channel:subscribe:CHANNAME
    }else if(dataIn.startsWith("channel:unsubscribe:")){ // client unsubscribes from channel
        // channel:unsubscribe:CHANNAME
    }else   if(cli->isbserver) { // Is another broadcast server???
        
        if(dataIn.startsWith("newid:")){ // sent from other server
            // newid:IP:ID
        }else if(dataIn.startsWith("newchannel:")){ // new messaging channel
            // newchannel:NAME
        }else  if(dataIn.startsWith("newsubscriber:")){ // new subscriber for the channel
            // newsubscriber:NAME:ID
        }else  if(dataIn.startsWith("unsubscriber:")){ // channel unsub
            // unsubscriber:NAME:ID
        }
    }
}