void GameObjectReplica::DeallocReplica(RakNet::Connection_RM3 *sourceConnection) {
		// note: if the source connection is null then the replicamanager is Deallocating
		//       the replicas he's created

		// the default implementation calls delete this !!!
		// we do not want this
		// instead we remove the actor from the scene
		// so - do not call the base class
#if SL_CODERVERSION_CP
		if(getPeer() != nullptr)	{
			getPeer()->log(ELogType_Message, "DeallocReplica: %s", getName().C_String());
		}
		else	{
			SL_PROCESS_APP()->log(ELogType_Message, "DeallocReplica: %s", getName().C_String());
		}
#endif
		// the 'default' implementation 'delete this'
		// would finally lead to the destructor implementation
		// of replica3
		// which does a final call to replica manager Dereference
		// so we mimic this implementation here
		// and set the replica manager to null afterwards

		// this might actually destroy the whole object
		// so we need to do smth to stay alive
		// until we leave the function
		if(_replicaComponent != nullptr)	{
			GameActorComponentPtr replicaComponentPtr(_replicaComponent);
			{
				replicaComponentPtr->removeFromGameplayLayer();
				_replicaComponent = nullptr;

				if (replicaManager)	{
					replicaManager->Dereference(this);
					// mimic the network id object destructor code
					if(GetNetworkIDManager() != nullptr)	{
						GetNetworkIDManager()->StopTrackingNetworkIDObject(this);
					}
					replicaManager = nullptr;
				}

				setPeer(nullptr);
			}
		}
		else	{
			if (replicaManager)	{
				replicaManager->Dereference(this);
				replicaManager = nullptr;
			}

			setPeer(nullptr);
		}
	}
Ejemplo n.º 2
0
    //==============================================================================
    void handleEvent (ComponentPeer& newPeer, Point<float> positionWithinPeer, Time time,
                      const ModifierKeys newMods, float newPressure)
    {
        lastTime = time;
        const bool pressureChanged = (pressure != newPressure);
        pressure = newPressure;
        ++mouseEventCounter;
        const Point<float> screenPos (newPeer.localToGlobal (positionWithinPeer));

        if (isDragging() && newMods.isAnyMouseButtonDown())
        {
            setScreenPos (screenPos, time, pressureChanged);
        }
        else
        {
            setPeer (newPeer, screenPos, time);

            if (ComponentPeer* peer = getPeer())
            {
                if (setButtons (screenPos, time, newMods))
                    return; // some modal events have been dispatched, so the current event is now out-of-date

                peer = getPeer();

                if (peer != nullptr)
                    setScreenPos (screenPos, time, pressureChanged);
            }
        }
    }
Ejemplo n.º 3
0
bool Connection::onRequestConnect() {
    QDataStream stream(this);

    QString name;
    stream >> name;
    setPeer(name);
    qDebug() << "user" << name << "try to connect";

    RsaKey key;
    stream >> key;
    setFriendRsaKey(key);

    QString key_str;
    stream >> key_str;
    twofish_key.set_str(key_str.toStdString().c_str(), 16);
    twofish_key = Rsa::crypt(twofish_key, ownPrivateKey);
    twofish = new Twofish(twofish_key, 128);

    QString answer = "REQUEST_CONNECT_OK";
    stream << answer;

    waitForBytesWritten();

    qDebug() << "connected";

    return true;
}
Ejemplo n.º 4
0
    //==============================================================================
    void handleEvent (ComponentPeer* const newPeer, Point<int> positionWithinPeer, Time time, const ModifierKeys newMods)
    {
        jassert (newPeer != nullptr);
        lastTime = time;
        ++mouseEventCounter;
        const Point<int> screenPos (newPeer->localToGlobal (positionWithinPeer));

        if (isDragging() && newMods.isAnyMouseButtonDown())
        {
            setScreenPos (screenPos, time, false);
        }
        else
        {
            setPeer (newPeer, screenPos, time);

            if (ComponentPeer* peer = getPeer())
            {
                if (setButtons (screenPos, time, newMods))
                    return; // some modal events have been dispatched, so the current event is now out-of-date

                peer = getPeer();
                if (peer != nullptr)
                    setScreenPos (screenPos, time, false);
            }
        }
    }
Ejemplo n.º 5
0
void UDPSocket::connect(const IPV4Host &ia, tpport_t port)
{
    setPeer(ia, port);
    if(so == INVALID_SOCKET)
        return;

    if(!::connect(so, (struct sockaddr *)&peer.ipv4, sizeof(struct sockaddr_in)))
        Socket::state = CONNECTED;
}
Ejemplo n.º 6
0
JNIEXPORT void JNICALL Java_com_codeminders_hidapi_HIDDevice_close
  (JNIEnv *env, jobject self)
{
    hid_device *peer = getPeer(env, self);
    if(!peer) 
    {
        throwIOException(env, peer);
        return; /* not an error, freed previously */ 
    }
    hid_close(peer);
    setPeer(env, self, NULL);
}
Ejemplo n.º 7
0
    Component* getTargetForGesture (ComponentPeer& peer, Point<float> positionWithinPeer,
                                    Time time, Point<float>& screenPos)
    {
        lastTime = time;
        ++mouseEventCounter;

        screenPos = peer.localToGlobal (positionWithinPeer);
        setPeer (peer, screenPos, time);
        setScreenPos (screenPos, time, false);
        triggerFakeMove();

        return isDragging() ? nullptr : getComponentUnderMouse();
    }
Ejemplo n.º 8
0
Socket::Error UDPReceive::connect(const ucommon::Socket::address &ia)
{
    ucommon::Socket::address host = ia;
    setPeer(host);

    // Win32 will crash if you try to connect to INADDR_ANY.
    if(host.isAny())
        host.setLoopback();

    if(::connect(so, host, host.getLength()))
        return connectError();
    return errSuccess;
}
Ejemplo n.º 9
0
void UDPSocket::connect(const char *service)
{
    int rtn = -1;

    setPeer(service);

    if(so == INVALID_SOCKET)
        return;

    rtn = ::connect(so, peer, peer.getLength());
    if(!rtn)
        Socket::state = CONNECTED;
}
Ejemplo n.º 10
0
void GaduFileTransferService::fileTransferReceived(Contact peer, QString downloadId, QString fileName)
{
	auto transfer = FileTransfer::create();
	transfer.setPeer(peer);
	transfer.setTransferDirection(FileTransferDirection::Incoming);
	transfer.setTransferType(FileTransferType::Url);
	transfer.setTransferStatus(FileTransferStatus::ReadyToDownload);
	transfer.setRemoteFileName(QUrl::fromPercentEncoding(fileName.toUtf8()));
	transfer.setFileSize(0); // we don't know file size yet
	transfer.addProperty("gg:downloadId", downloadId, CustomProperties::Storable);
	transfer.addProperty("gg:remoteFileName", fileName, CustomProperties::Storable);

	emit incomingFileTransfer(transfer);
}
Ejemplo n.º 11
0
    Component* getTargetForGesture (ComponentPeer* const peer, const Point<int>& positionWithinPeer,
                                    const Time& time, Point<int>& screenPos)
    {
        jassert (peer != nullptr);
        lastTime = time;
        ++mouseEventCounter;

        screenPos = peer->localToGlobal (positionWithinPeer);
        setPeer (peer, screenPos, time);
        setScreenPos (screenPos, time, false);
        triggerFakeMove();

        return isDragging() ? nullptr : getComponentUnderMouse();
    }
Ejemplo n.º 12
0
int UDPSocket::recv(void * buffer, size_t length, int flags )
{
  int recv_ret;
  struct sockaddr_storage remote_addr;
   socklen_t sin_len = sizeof remote_addr;

  #ifdef WIN32
  if(SOCK_ERR==(recv_ret=::recvfrom(getSockFD(),(char *)buffer,length,flags,
                           (struct sockaddr*)&remote_addr,&sin_len)))
  #else
  if(!(recv_ret=::recvfrom(getSockFD(),(void *)buffer,length,flags,
                           (struct sockaddr*)&remote_addr,&sin_len)))
  #endif
    throw new ExUDPSocket(E_RECVFROM_FAIL);
    setPeer((struct addrinfo *)&remote_addr);
  return recv_ret;
}
Ejemplo n.º 13
0
    void handleWheel (ComponentPeer* const peer, const Point<int>& positionWithinPeer, const Time& time, float x, float y)
    {
        jassert (peer != nullptr);
        lastTime = time;
        ++mouseEventCounter;
        const Point<int> screenPos (peer->localToGlobal (positionWithinPeer));

        setPeer (peer, screenPos, time);
        setScreenPos (screenPos, time, false);
        triggerFakeMove();

        if (! isDragging())
        {
            Component* current = getComponentUnderMouse();
            if (current != nullptr)
                sendMouseWheel (current, screenPos, time, x, y);
        }
    }
Ejemplo n.º 14
0
    void handleWheel (ComponentPeer* const peer, const Point<int>& positionWithinPeer,
                      const Time& time, const MouseWheelDetails& wheel)
    {
        jassert (peer != nullptr);
        lastTime = time;
        ++mouseEventCounter;
        Desktop::getInstance().incrementMouseWheelCounter();

        const Point<int> screenPos (peer->localToGlobal (positionWithinPeer));
        setPeer (peer, screenPos, time);
        setScreenPos (screenPos, time, false);
        triggerFakeMove();

        if (! isDragging())
        {
            Component* current = getComponentUnderMouse();
            if (current != nullptr)
                sendMouseWheel (current, screenPos, time, wheel);
        }
    }
Ejemplo n.º 15
0
void JabberFileTransferService::fileReceived(QXmppTransferJob *transferJob)
{
    auto jid = Jid::parse(transferJob->jid());
    auto peer = m_contactManager->byId(m_account, jid.bare(), ActionCreateAndAdd);

    auto transfer = m_fileTransferStorage->create();
    transfer.setPeer(peer);
    transfer.setTransferDirection(FileTransferDirection::Incoming);
    transfer.setTransferType(FileTransferType::Stream);
    transfer.setTransferStatus(FileTransferStatus::WaitingForAccept);
    transfer.setRemoteFileName(transferJob->fileName());
    transfer.setFileSize(transferJob->fileSize());

    if (!m_fileTransferHandlerManager->ensureHandler(transfer))
        return;

    auto handler = qobject_cast<JabberStreamIncomingFileTransferHandler *>(transfer.handler());
    if (handler)
        handler->setTransferJob(transferJob);

    emit incomingFileTransfer(transfer);
}
Ejemplo n.º 16
0
ucommon::Socket::address UDPSocket::getPeer()
{
    ucommon::Socket::address addr = getPeer();
    setPeer(addr);
    return addr;
}