OsclConnectMethod::~OsclConnectMethod()
{
    if (ConnectRequest())
    {
        ConnectRequest()->~OsclConnectRequest();
        Alloc().deallocate(ConnectRequest());
    }
}
void
BluetoothServiceChildProcess::Connect(
  const BluetoothAddress& aDeviceAddress,
  uint32_t aCod, uint16_t aServiceUuid,
  BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable, ConnectRequest(aDeviceAddress, aCod, aServiceUuid));
}
void
BluetoothServiceChildProcess::Connect(
  const nsAString& aDeviceAddress,
  const uint16_t aProfileId,
  BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable,
              ConnectRequest(nsString(aDeviceAddress),
                             aProfileId));
}
TPVSocketEvent OsclConnectMethod::Connect(OsclNetworkAddress& aAddress,
        int32 aTimeout)
{
    if (!StartMethod(aTimeout))
        return EPVSocketFailure;

    ConnectRequest()->Connect(aAddress);

    return EPVSocketPending;
}
void Dispatcher::run()
{
  while(1)
  {
	  TCPSocket* speaker = multiListener->listenToSocket(10);
	  if(speaker!=NULL)
	  {
	  int cmd;
	  speaker->recv((char*)&cmd,4);
	  cmd = ntohl(cmd);
	  switch(cmd)
		  {
	      case SESSION_ESTABLISHED:
		      cout<<"connected";
	    	  break;

		  case OPEN_SESSION_WITH_PEER:
			  {string dest = ReceiveMsg(speaker);
			   ConnectRequest(speaker->destIpAndPort(),dest);}
			   break;

		  case USER_LIST:
			   sendUserList(speaker);
			   break;

		  case ROOM_LIST:
			   sendRoomList(speaker);
			   break;

		  case MEMBERS_LIST:
			  {string room = ReceiveMsg(speaker);
			   sendMembersList(speaker,room);}
			   break;

		  case CREATE_CHAT:
			   SetActiveChat(speaker->destIpAndPort());
			   break;

		  case CLOSE_CHAT:
			   CloseUserChat(speaker->destIpAndPort());
			   break;

		  case CLOSE_SESSION_WITH_PEER:
			   closePeer(speaker->destIpAndPort());
			   break;

		  default:
		  break;
		 }
	   }
   }
}
bool
BluetoothServiceChildProcess::Connect(
  const nsAString& aDeviceAddress,
  const nsAString& aAdapterPath,
  const uint16_t aProfileId,
  BluetoothReplyRunnable* aRunnable)
{
  SendRequest(aRunnable,
              ConnectRequest(nsString(aDeviceAddress), 
                             nsString(aAdapterPath),
                             aProfileId));

  return true;
}