2013-11-29 08:13:44 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-05-10 05:00:28 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_UDPSocketParent_h__
|
|
|
|
#define mozilla_dom_UDPSocketParent_h__
|
|
|
|
|
|
|
|
#include "mozilla/net/PUDPSocketParent.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIUDPSocket.h"
|
2013-11-29 08:13:44 -08:00
|
|
|
#include "nsIUDPSocketFilter.h"
|
2013-05-10 05:00:28 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class UDPSocketParent : public mozilla::net::PUDPSocketParent
|
|
|
|
, public nsIUDPSocketListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSIUDPSOCKETLISTENER
|
|
|
|
|
2014-08-26 16:34:46 -07:00
|
|
|
explicit UDPSocketParent(nsIUDPSocketFilter* filter) :
|
|
|
|
mIPCOpen(true),
|
|
|
|
mFilter(filter) {}
|
2013-11-29 08:13:44 -08:00
|
|
|
|
2014-08-26 16:33:42 -07:00
|
|
|
bool Init(const nsCString& aHost, const uint16_t aPort);
|
2013-05-10 05:00:28 -07:00
|
|
|
|
|
|
|
virtual bool RecvClose() MOZ_OVERRIDE;
|
2014-08-26 16:33:42 -07:00
|
|
|
virtual bool RecvData(const InfallibleTArray<uint8_t>& aData,
|
|
|
|
const nsCString& aRemoteAddress,
|
|
|
|
const uint16_t& aPort) MOZ_OVERRIDE;
|
|
|
|
virtual bool RecvDataWithAddress( const InfallibleTArray<uint8_t>& data,
|
|
|
|
const mozilla::net::NetAddr& addr);
|
2013-05-10 05:00:28 -07:00
|
|
|
virtual bool RecvRequestDelete() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
2014-06-23 12:56:07 -07:00
|
|
|
virtual ~UDPSocketParent();
|
|
|
|
|
2013-05-10 05:00:28 -07:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
bool mIPCOpen;
|
|
|
|
nsCOMPtr<nsIUDPSocket> mSocket;
|
2013-11-29 08:13:44 -08:00
|
|
|
nsCOMPtr<nsIUDPSocketFilter> mFilter;
|
2013-05-10 05:00:28 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // !defined(mozilla_dom_UDPSocketParent_h__)
|