New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

msg-js-ipc

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msg-js-ipc

msg-js-ipc (msg JavaScript Inter Process Communication) handles the communication between two windows on different domains

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

msg-js-ipc

Inter-Process-Communication (IPC) Library for JavaScript. This Library enables communicating between two windows on different domains. The communication can be bidirectional, so every window itself can be both a sender and a recipient. To make the communication between two windows work, both of them must include the same version of msg-js-ipc.

msg-js-ipc is based on please.js, a Request/Response based wrapper around the PostMessage API that makes use of jQuery Promises. please.js itself is based on top of jQuery and the jQuery Promise API.

Installation

Before start using msg-js-ipc, you must make sure that both windows have msg-js-ipc loaded and thus the global object IPC is available.

Install with npm

$ npm install msg-js-ipc

or download source.

##Usage

###Sender

To send an event, just call the method sendEvent on the global object IPC.

	IPC.sendEvent(window.parent, 'ipc_infoText', text)

The method sendEvent has the following parameter:

  • The target window (recipient)
  • The name of the recipient's method as string
  • [optional] further parameters (0-n), as many as the implementation of the given method expects

For example we have a window A that includes an iFrame B. Then the target window of A is the iFrame B ($('iframe').get(0).contentWindow) and the target window of the iFrame B is the window A (window.parent).

In case the sender tries to call a method the recipient has not implemented, an error is thrown from the msg-js-ipc Library.

###Recipient

To receive an event, the recipient must register its implementation on the global object IPC.

	IPC.registerRecipient(this)

Furthermore the recipient has to implement the methods, that the sender wants to call.

	ipc_infoText (text) {
        // the implementation of the method
        // here u can give the information back in the application and convert it to the applications architecture
    },

All methods, the recipient provides for the communication with a sender, must start with the prefix ipc_. That is for security reason to avoid that everything the recipient implements can be called from a sender. Only through the prefix ipc_ the method is available for a sender. If the sender tries to call a method, that does not start with the prefix ipc_, an error is thrown from the msg-js-ipc Library.

Keywords

inter

FAQs

Package last updated on 09 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts