webchanneltransport.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2013 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Transport support for WebChannel.
  16. *
  17. * The <code>WebChannelTransport</code> implementation serves as the factory
  18. * for <code>WebChannel</code>, which offers an abstraction for
  19. * point-to-point socket-like communication similar to what BrowserChannel
  20. * or HTML5 WebSocket offers.
  21. *
  22. */
  23. goog.provide('goog.net.WebChannelTransport');
  24. /**
  25. * A WebChannelTransport instance represents a shared context of logical
  26. * connectivity between a browser client and a remote origin.
  27. *
  28. * Over a single WebChannelTransport instance, multiple WebChannels may be
  29. * created against different URLs, which may all share the same
  30. * underlying connectivity (i.e. TCP connection) whenever possible.
  31. *
  32. * When multi-domains are supported, such as CORS, multiple origins may be
  33. * supported over a single WebChannelTransport instance at the same time.
  34. *
  35. * Sharing between different window contexts such as tabs is not addressed
  36. * by WebChannelTransport. Applications may choose HTML5 shared workers
  37. * or other techniques to access the same transport instance
  38. * across different window contexts.
  39. *
  40. * @interface
  41. */
  42. goog.net.WebChannelTransport = function() {};
  43. /**
  44. * The client version. This integer value will be passed to the server
  45. * when a channel is opened to inform the server the client "capabilities".
  46. *
  47. * Wire protocol version is a different concept and is internal to the
  48. * transport implementation.
  49. *
  50. * @const
  51. * @type {number}
  52. */
  53. goog.net.WebChannelTransport.CLIENT_VERSION = 20;
  54. /**
  55. * Create a new WebChannel instance.
  56. *
  57. * The new WebChannel is to be opened against the server-side resource
  58. * as specified by the given URL. See {@link goog.net.WebChannel} for detailed
  59. * semantics.
  60. *
  61. * @param {string} url The URL path for the new WebChannel instance.
  62. * @param {!goog.net.WebChannel.Options=} opt_options Configuration for the
  63. * new WebChannel instance. The configuration object is reusable after
  64. * the new channel instance is created.
  65. * @return {!goog.net.WebChannel} the newly created WebChannel instance.
  66. */
  67. goog.net.WebChannelTransport.prototype.createWebChannel = goog.abstractMethod;