Skip to content

Commit

Permalink
Merge branch 'binary'
Browse files Browse the repository at this point in the history
  • Loading branch information
OmniacDev committed Jan 14, 2025
2 parents 6fcfc12 + 94a6830 commit 2b51673
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 90 deletions.
72 changes: 1 addition & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,74 +17,4 @@ An IPC[^1] system for MCBE Script API projects

**TypeScript**
1. Download `ipc.ts` from the latest [release](https://github.com/OmniacDev/MCBE-IPC/releases/latest)
2. Copy file into your project

## Usage

### Sending & Receiving

`IPC.send()` and `IPC.on()` can be used to send messages or data between packs.

_Pack 1_
```js
import IPC from 'ipc.js'

IPC.on('message_channel', (args) => {
console.log(`Message: ${args}`)
})

IPC.on('data_channel', (args) => {
console.log(`Data: ${args.example_bool}, ${args.example_number}`)
})
```
_Pack 2_
```js
import IPC from 'ipc.js'

IPC.send('message_channel', 'Example Message')

IPC.send('data_channel', { example_number: 100, example_bool: true })
```
_Console Output_
```
Message: Example Message
Data: true, 100
```

### Requesting & Serving

`IPC.invoke()` and `IPC.handle()` can be used to request and serve data between packs.

_Pack 1_
```js
import IPC from 'ipc.js'

IPC.handle('request_channel', (args) => {
switch (args) {
case 'status':
return 'inactive'
case 'size':
return 100
}
})
```
_Pack 2_
```js
import IPC from 'ipc.js'

IPC.invoke('request_channel', 'status').then(result => {
console.log(`Status: ${result}`)
})

IPC.invoke('request_channel', 'size').then(result => {
console.log(`Size: ${result}`)
})
```
_Console Output_
```
Status: inactive
Size: 100
```



2. Copy file into your project
18 changes: 0 additions & 18 deletions TYPES.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "OmniacDev",
"description": "IPC system for MCBE Script API projects",
"license": "MIT",
"version": "2.0.1",
"version": "3.0.0",
"repository": {
"type": "git",
"url": "https://github.com/OmniacDev/mcbe-ipc.git"
Expand Down

0 comments on commit 2b51673

Please sign in to comment.