All Projects → pshihn → Windtalk

pshihn / Windtalk

Licence: mit
Simplest way to communicate with iFrames and other windows

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Windtalk

plain-overlay
The simple library for customizable overlay which covers a page, elements or iframe-windows.
Stars: ✭ 28 (-72%)
Mutual labels:  window, iframe
Pool
General Purpose Connection Pool for GRPC,RPC,TCP Sevice Cluster
Stars: ✭ 98 (-2%)
Mutual labels:  rpc
Chrome Protocol Proxy
Chrome DevTools Protocol Proxy - intelligent proxy for debugging purposes
Stars: ✭ 94 (-6%)
Mutual labels:  proxy
Autobahn Js
WAMP in JavaScript for Browsers and NodeJS
Stars: ✭ 1,345 (+1245%)
Mutual labels:  rpc
Cocsharp
Clash of Clans library, proxy and server written in .NET [Unmaintained]
Stars: ✭ 94 (-6%)
Mutual labels:  proxy
Agentframework
An elegant & efficient TypeScript metaprogramming API to build software agents
Stars: ✭ 97 (-3%)
Mutual labels:  proxy
X
新生命X组件,数据中间件XCode、日志、网络、RPC、序列化、缓存、Windows服务
Stars: ✭ 1,322 (+1222%)
Mutual labels:  rpc
Bettercap
The Swiss Army knife for 802.11, BLE, IPv4 and IPv6 networks reconnaissance and MITM attacks.
Stars: ✭ 10,735 (+10635%)
Mutual labels:  proxy
Multirpc
A Discord rich presence manager app with a cool GUI and support for custom status and multiple profiles
Stars: ✭ 94 (-6%)
Mutual labels:  rpc
Sozu
Sōzu HTTP reverse proxy, configurable at runtime, fast and safe, built in Rust. It is awesome! Ping us on gitter to know more
Stars: ✭ 1,341 (+1241%)
Mutual labels:  proxy
Smgate
用树莓派做v2ray透明翻墙网关
Stars: ✭ 96 (-4%)
Mutual labels:  proxy
Remote Function
Make function calls to remote hosts seamlessly
Stars: ✭ 95 (-5%)
Mutual labels:  rpc
Sidedoor
SSH connection daemon for Debian/Raspbian/Ubuntu/etc
Stars: ✭ 97 (-3%)
Mutual labels:  proxy
Nitmproxy
Proxy server based on netty
Stars: ✭ 94 (-6%)
Mutual labels:  proxy
Proxy
C++ TCP Proxy Server
Stars: ✭ 98 (-2%)
Mutual labels:  proxy
Wheel
Quick navigation framework for Vim and Neovim : buffer groups, mru, locate, find, grep, outline, yank, ...
Stars: ✭ 94 (-6%)
Mutual labels:  window
Python Binance Chain
Binance Chain Exchange API python implementation for automated trading
Stars: ✭ 96 (-4%)
Mutual labels:  rpc
Vue Mpc
multiple pages (multiple entries) based on vue-cli3.x(基于vue-cli3.x创建的多页面应用,每个页面入口又可以创建自己的vue-router)
Stars: ✭ 97 (-3%)
Mutual labels:  iframe
Simpletcp
Simple wrapper for TCP client and server in C# with SSL support
Stars: ✭ 99 (-1%)
Mutual labels:  rpc
Rpc.py
A fast and powerful RPC framework based on ASGI/WSGI.
Stars: ✭ 98 (-2%)
Mutual labels:  rpc

windtalk banner

WindTalk

A seamless way for two WINDows to TALK to each other.

Windtalk exports a function or an object from within an iFrame or Window. This can now be invoked from any other window.

  • All calls are async. Works great with async/await
  • Only 677 bytes gzipped

Motivation

How does code in one window communicate with an iFrame or another window?

The traditional way to do this is by passing messages (See postMessage). The host window will send a message to iFrame. iFrame will receive a message, parse the message and then call some code. The iFrame will then take the result of the code and then send a message to the host window with the result. The host window will now receive the message, parse it, and then call its own code.

In theory, this is fine. One can wrap this boilerplate message parsing to make the life easier. But when you have new code to add, you have to add another if clause in message parsing and then call the new code.

Wouldn't it be nice if we could just call the code in the other window like any other code!

objectInIframe.name = 'Bilbo Baggins';
await objectInIframe.updateProfile();
objectInIframe.resize();

This is possible to achieve if all the message boilerplate code is tethered behind a proxy.

This is where WindTalk comes in and provides you with that capability.

Usage

WindTalk is essentially two methods:

expose makes a function or object available to other windows.

link creates an interface for the exposed method/object in another winow

Let's consider a case where a parent window wants to interact with an object in an iframe.

In the iframe:

const color = {
  red: 0,
  green: 0,
  blue: 0,
  update: function () {
    // update the ui
  }
};
windtalk.expose(color);

In parent window:

const color = windtalk.link(iframe.contentWindow);
color.red = 200;
color.green = 150;
color.blue = 10;
color.update();

Expose Functions (not just objects)

Window1:

function doAdd(a, b) {
  return a + b;
}
windtalk.expose(doAdd);

Window2:

const doAdd = windtalk.link(win1);
let result = await doAdd(2, 3);
console.log(result); // 5

Bidirectional

Code in an iFrame can be invoked from the parent Window, and vice versa. Any one can invoke the exposed object if they have a reference to the Window object.

Install

Download the latest from dist folder

or from npm:

npm install --save windtalk

use it in ES6 modules:

import { expose, link } from 'windtalk';

License

MIT License (c) Preet Shihn

You may also be interested in

Workly - A really simple way to move a function or class to a web worker. Or, expose a function or object in a web worker to the main thread.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].