Exemple #1
0
void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context)
{
	if (mf_info_lock(mfi) > 0)
	{
		int i;
		int peerId;
		if (mfi->peerCount == MF_INFO_MAXPEERS)
		{
            printf("TODO: socketClose on OS X\n");
			//context->socketClose = TRUE;
			mf_info_unlock(mfi);
			return;
		}

		context->info = mfi;
		
		//get the offset of the top left corner of selected screen
		//EnumDisplayMonitors(NULL, NULL, mf_info_monEnumCB, 0);
		//_IDcount = 0;

        //initialize screen capture
		if (mfi->peerCount == 0)
        {
            mf_mlion_display_info(&mfi->servscreen_width, &mfi->servscreen_height, &mfi->scale);
            mf_mlion_screen_updates_init();
            mf_mlion_start_getting_screen_updates();
        }
			
		//look trhough the array of peers until an empty slot
		for(i=0; i<MF_INFO_MAXPEERS; ++i)
		{
			//empty index will be our peer id
			if (mfi->peers[i] == NULL)
			{
				peerId = i;
				break;
			}
		}

		mfi->peers[peerId] = ((rdpContext*) context)->peer;
		mfi->peers[peerId]->pId = peerId;
		mfi->peerCount++;
		printf("Registering Peer: id=%d #=%d\n", peerId, mfi->peerCount);

		mf_info_unlock(mfi);

		//mfreerdp_server_peer_callback_event(peerId, MF_SRV_CALLBACK_EVENT_CONNECT);
	}
}
Exemple #2
0
void mf_info_peer_unregister(mfInfo* mfi, mfPeerContext* context)
{
	if (mf_info_lock(mfi) > 0)
	{
		int peerId;
		
		peerId = ((rdpContext*) context)->peer->pId;
		mfi->peers[peerId] = NULL;
		mfi->peerCount--;
		
		if (mfi->peerCount == 0)
			mf_mlion_stop_getting_screen_updates();

		mf_info_unlock(mfi);
	}
}
Exemple #3
0
void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context)
{
	if (mf_info_lock(mfi) > 0)
	{
		int i;
		int peerId;
		
		if (mfi->peerCount == MF_INFO_MAXPEERS)
		{
			mf_info_unlock(mfi);
			return;
		}
		
		context->info = mfi;
		
		if (mfi->peerCount == 0)
		{
			mf_mlion_display_info(&mfi->servscreen_width, &mfi->servscreen_height, &mfi->scale);
			mf_mlion_screen_updates_init();
			mf_mlion_start_getting_screen_updates();
		}
		
		peerId = NULL;

		for(i=0; i<MF_INFO_MAXPEERS; ++i)
		{
			//empty index will be our peer id
			if (mfi->peers[i] == NULL)
			{
				peerId = i;
				break;
			}
		}
		
		mfi->peers[peerId] = ((rdpContext*) context)->peer;
		mfi->peers[peerId]->pId = peerId;
		mfi->peerCount++;
		
		mf_info_unlock(mfi);
	}
}
Exemple #4
0
void mf_info_peer_unregister(mfInfo* mfi, mfPeerContext* context)
{
	if (mf_info_lock(mfi) > 0)
	{
		int peerId;

		peerId = ((rdpContext*) context)->peer->pId;
		mfi->peers[peerId] = NULL;
		mfi->peerCount--;

		printf("Unregistering Peer: id=%d, #=%d\n", peerId, mfi->peerCount);

        //screen capture cleanup
		if (mfi->peerCount == 0)
        {
            mf_mlion_stop_getting_screen_updates();
        }
		mf_info_unlock(mfi);

		//mfreerdp_server_peer_callback_event(peerId, MF_SRV_CALLBACK_EVENT_DISCONNECT);
	}
}