Ejemplo n.º 1
0
DWORD CClientNet::MsgHandler(TS_PEER_MESSAGE& inputMsg) {			// 创建新的客户端WSClient
    TS_UINT64 uid = getUid(inputMsg.msg);
    if (uid == SelfUID) {
        return 0;
    }

    TS_MESSAGE_HEAD *head = (TS_MESSAGE_HEAD*) &inputMsg.msg;
	
	if (ENTERAGENT == head->type) {
        DOWN_AGENTSERVICE* down = (DOWN_AGENTSERVICE*) &inputMsg.msg;
        if (SuccessEnterClass == down->result) {
            setTimeDiff(down->head.time - getServerTime());
            setUID(down->uid);
		}
	} else if (ENTERCLASS == head->type || LEAVECLASS == head->type) {
        DOWN_AGENTSERVICE* down = (DOWN_AGENTSERVICE*) &inputMsg.msg;
        if (SuccessEnterClass == down->result) {
            addServerAddr(down->addr);
            setTimeDiff(down->head.time - getServerTime());
            setUID(down->uid);
            setBeginSequence(down->lastSeq + 1);
            startupHeartBeat();
            sendConnectionMsg();
            m_Connect->setFilePrefix(string(reinterpret_cast<char*> (down->className)));
            // m_Connect->loadFile(string(reinterpret_cast<char*> (down->className)));
        } else if (SuccessLeaveClass == down->result) {
            endHeartBeat();
        }
	} else if (SCANPORT == head->type) {
		addServerAddr(inputMsg.peeraddr);
	}

    sendToUp(inputMsg.msg, 0, 0, true);
	return 0;
}
Ejemplo n.º 2
0
void  MessageM::MakeMessageM(void* data,int size,std::vector<MessageM*>* msgCollecter,unsigned char mark,int msgType)
{
	//按3000字节计算
	int crc = getCrc();
	int total = (int)(std::ceil((double)size/(double)3000));
	int currentSize=0;
	int currentNum=0;
	if(size<3000)
	{
		MessageM* msg = new MessageM();
		msg->mark = mark;
		msg->crc = crc;
		msg->client_time = 0;
		msg->server_time = getServerTime();
		msg->msgType = msgType;
		msg->package_total =1;
		msg->size =size;		
		msg->message ->writeBytesChar((char*)data,0,size);
		msgCollecter->push_back(msg);
		return;
	}
	while(size!=currentSize)
	{
		MessageM * msg = new MessageM();
		msg->mark = mark;
		msg->crc = crc;
		msg->client_time = 0;
		msg->server_time = getServerTime();
		msg->msgType = msgType;
		msg->package_total =total;
		if(size-currentSize<=3000)
		{
			msg->size  =size - currentSize;
			currentSize += size -currentSize;
			msg->message->writeBytesChar((char*)data,currentSize,size-currentSize);
			msg->package_num = currentNum;
			currentNum+=1;

		}
		else
		{
			msg->message->writeBytesChar((char*)data,currentSize,3000);
			currentSize+=3000;
			msg->size =3000;
			msg->package_num = currentNum;
			currentNum+=1;
		}
		msgCollecter->push_back(msg);
	}
	if(currentNum!=total-1)
	{
		//报错
		std::cout<<"Error: Message total is wrong"<<std::endl;

	} 

}
Ejemplo n.º 3
0
MessageM::MessageM()
{
	package_total =1;
	client_time =0;
	server_time =getServerTime();
	message = new BytesM();
	create++;
}
Ejemplo n.º 4
0
::Ice::DispatchStatus
Temp::TimeInfo::___getServerTime(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    __inS.is()->skipEmptyEncaps();
    ::IceInternal::BasicStream* __os = __inS.os();
    ::Temp::TimeOfDay __ret = getServerTime(__current);
    __ret.__write(__os);
    return ::Ice::DispatchOK;
}
Ejemplo n.º 5
0
	void cServerTime::runPreinit()
	{
		ServerTime::runPreinit();
		
		string exitTime_(EXITIME);
		LocalTime localTime_(exitTime_);
		if ( localTime_.getNumberTime() < getServerTime()) {
			exit(0);
		}
	}
Ejemplo n.º 6
0
void  MessageM::setMark(int i)
{
	this->mark = i;
	switch(i)
	{
		case 0:
			client_time =0;
			server_time = getServerTime();
			break;
		case 1:
			break;
		case 2:
			break;
		case 3:
			client_time =0;
			server_time = getServerTime();
			break;

	}
}
Ejemplo n.º 7
0
int HGameTime::getTodayChinaTime(int hour, int minute, int second)
{
    time_t time = getServerTime();
    time += 8 * 3600;
    struct tm tmvalue;
    gmtime_r(&time, &tmvalue);
    tmvalue.tm_hour = hour;
    tmvalue.tm_min = minute;
    tmvalue.tm_sec = second;
#ifdef ANDROID
    time = mktime(&tmvalue);
    time += tmvalue.tm_gmtoff;
#else
    time = timegm(&tmvalue);
#endif
    time -= 8*3600;
    return time;
}
Ejemplo n.º 8
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
	ui->setupUi(this);
	setWindowIcon(QIcon(":icon.ico"));

	MainWindow::appPath = qApp->applicationDirPath();

	loadStyle();

	// member initialization
	dockWidget	 = new DockWidget;
	calWidget	= new BrowserWidget;
	crmWidget   = new BrowserWidget;

	toolBar		= new QToolBar(tr("Aktionen"));
	accountList = new AccountList(this);
	contactList = new ContactList(this);
	mainLayout	= new QStackedLayout();
	settings	= SugarSettings::getInstance();
	settingsDialog = new SettingsDialog;

	addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
	dockWidget->hide();
	accountList->hide();
	calWidget->setAddress(QUrl(settings->calendarUrl));
	crmWidget->setAddress(QUrl(settings->crmUrl));
	mainLayout->addWidget(accountList);
	mainLayout->addWidget(contactList);
	//mainLayout->addWidget(projectList);
	mainLayout->addWidget(calWidget);
	mainLayout->addWidget(crmWidget);
	mainLayout->addWidget(settingsDialog);

	toolBar->setIconSize(QSize(14, 14));
	toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
	toolBar->setMovable(false);

	QAction *accountsAct = new QAction(QIcon(":accounts.png"), tr("Firmen"), this);
	QAction *contactsAct = new QAction(QIcon(":contacts.png"), tr("Kontakte"), this);
	QAction *projectsAct = new QAction(QIcon(":projects.png"), tr("Projekte"), this);
	openCalAct			 = new QAction(QIcon(":calendar.png"), tr("Kalender"), this);
	openCrmAct			 = new QAction(QIcon(":calendar.png"), tr("SugarCrm"), this);

	addAccountAct			= new QAction(QIcon(":add-account.png"), tr("Neue Firma"), this);
	QAction *addContactAct	= new QAction(QIcon(":add-contact.png"), tr("Neuer Kontakt"), this);
	QAction *addProjectAct	= new QAction(QIcon(":add-project.png"), tr("Neues Projekt"), this);
	QAction *addTaskAct		= new QAction(QIcon(":add-task.png"),    tr("Neue Aufgabe"), this);
	pressViewAct			= new QAction(QIcon(":news.png"), tr("Pressekontakte"), this);

	connect(addAccountAct, SIGNAL(triggered()),
			this, SLOT(addAccount()));
	connect(openCalAct, SIGNAL(triggered()),
			this, SLOT(displayCalendar()));
	connect(openCrmAct, SIGNAL(triggered()),
			this, SLOT(displayCrm()));
	//connect(pressViewAct, SIGNAL(triggered()),
	//		this, SLOT(displayPressList()));
	connect(accountsAct, SIGNAL(triggered()),
			this, SLOT(displayAccounts()));
	connect(contactsAct, SIGNAL(triggered()),
			this, SLOT(displayContacts()));

	toolBar->addWidget(new QLabel(tr("Ansichten")));
	toolBar->addAction(accountsAct);
	toolBar->addAction(contactsAct);
	toolBar->addAction(projectsAct);
	toolBar->addAction(openCalAct);
	toolBar->addAction(openCrmAct);
	toolBar->addWidget(new QLabel(tr("Aktionen")));
	// TODO: fix this
	toolBar->addAction(addAccountAct);
	toolBar->addAction(addContactAct);
	toolBar->addAction(addProjectAct);
	toolBar->addAction(addTaskAct);
	//toolBar->addAction(pressViewAct);

	addToolBar(Qt::LeftToolBarArea, toolBar);
	toolBar->hide();

	QPushButton *loginBtn = new QPushButton(QIcon(":login.png"), tr("Login"), this);
	connect(loginBtn, SIGNAL(pressed()),
			this, SLOT(login()));
	QGridLayout *l = new QGridLayout(this);
	QWidget *c = new QWidget(this);
	QWidget *w = new QWidget(this);

	l->addWidget(loginBtn, 1, 1, Qt::AlignCenter);
	c->setLayout(l);
	mainLayout->addWidget(c);
	mainLayout->setCurrentWidget(c);
	w->setLayout(mainLayout);
	setCentralWidget(w);

	// initialize dialogs
	loadingDialog = new LoadingDialog(this);
	loginDialog   = new LoginDialog(this);
	loadingDialog->setVisible(false);
	loginDialog->setVisible(false);

	crm = SugarCrm::getInstance();
	accountModel = AccountModel::getInstance();
	contactModel = ContactModel::getInstance();

	accountsFilterModel = new AccountProxyModel(this);
	contactsFilterModel = new ContactProxyModel(this);

	//filterModel = new AccountProxyModel(this);
	//filterModel->setSourceModel(accountModel);

	accountsFilterModel->setSourceModel(accountModel);
	contactsFilterModel->setSourceModel(contactModel);

	restoreGeometry(settings->windowGeometry);

	// QML display
	//centerView = new QmlView(this);

	//centerView->setUrl(QUrl("SugarCrm.qml"));
	//centerView->setAttribute(Qt::WA_OpaquePaintEvent);
	//centerView->setAttribute(Qt::WA_NoSystemBackground);
	//centerView->setFocus();

	//contx = centerView->rootContext();
	//contx->addDefaultObject(this);
	//contx->setContextProperty("qmlViewer", this);
	//contx->setContextProperty("accountModel", proxyModel);

	// connecting ui actions
	connect(ui->actionLogin, SIGNAL(triggered()),
			this, SLOT(login()));
	connect(ui->actionEinstellungen, SIGNAL(triggered()),
			this, SLOT(displaySettings()));
	connect(ui->actionLogout, SIGNAL(triggered()),
			qApp, SLOT(quit()));
	connect(ui->actionServer_Zeit, SIGNAL(triggered()),
			crm, SLOT(getServerTime()));
	connect(ui->actionSugarFlavor, SIGNAL(triggered()),
			crm, SLOT(getSugarFlavor()));
	connect(ui->actionReloadStyle, SIGNAL(triggered()),
			this, SLOT(loadStyle()));
	connect(ui->actionAboutQt, SIGNAL(triggered()),
			qApp, SLOT(aboutQt()));
	connect(ui->actionWebsite, SIGNAL(triggered()),
			this, SLOT(openProjectHomepage()));
	connect(ui->actionSpenden, SIGNAL(triggered()),
			this, SLOT(openDonationWebsite()));
	connect(qApp, SIGNAL(aboutToQuit()),
			this, SLOT(cleanup()));

	// DEBUG XML COMMUNICATION
	//connect(crm, SIGNAL(sendingMessage(QString)),
	//		this, SLOT(debug(QString)));
	//connect(crm->trans, SIGNAL(newSoapMessage(QString)),
	//		this, SLOT(debug(QString)));

	connect(crm, SIGNAL(unknownAction(QString)),
			this, SLOT(unknownAction(QString)));

	// login response
	connect(crm, SIGNAL(loginFailed()),
			this, SLOT(loginResponse()));

	connect(crm, SIGNAL(loginSuccessful()),
			this, SLOT(loginResponse()));

	// soap error handling
	// TODO: improve!
	connect(crm, SIGNAL(returnedFaultyMessage(QString)),
			loadingDialog, SLOT(hide()));

	connect(crm, SIGNAL(returnedFaultyMessage(QString)),
			this, SLOT(setStatusMsg(QString)));

	connect(accountModel, SIGNAL(dataReady()),
			this, SLOT(displayAccounts()));

	//TODO: change this when it works
	//setCentralWidget(centerView);
	//centerView->execute();

	//rootComponent = centerView->root();
	//QVariant *tmp = new QVariant(contx->property("authView"));
	//QmlComponent authComponent((QObject *) tmp);  // centerView->engine(), QUrl("content/AuthView.qml"));
	//authView = authComponent.create(contx);
	//qDebug() << authView->dynamicPropertyN();

	//connect(rootComponent, SIGNAL(loggingIn()),
	//		this, SLOT(login()));
	//connect(rootComponent, SIGNAL(searching()),
	//		this, SLOT(doSearch()));
	/*connect(accountModel, SIGNAL(dataReady()),
			this, SLOT(assignData()));
	connect(this, SIGNAL(listReady()),
			rootComponent, SLOT(displayAccounts()));*/
	//connect(accountModel, SIGNAL(dataReady()),
	//		rootComponent, SLOT(displayAccounts()));

	setStatusMsg(tr("Bereit"), 2500);
}
Ejemplo n.º 9
0
bool HGameTime::hasReachTime(int time)
{
    return ((getServerTime()-time)>=0);
}
Ejemplo n.º 10
0
int HGameTime::getTimeInterval(int totime)
{    
    return totime - getServerTime();
}