Skip to content

v1.4.0

Compare
Choose a tag to compare
@OmniacDev OmniacDev released this 05 Sep 07:29
· 153 commits to main since this release
48bcc3f
  • Added functionality for direct communication between packs.

    Both packs must use the ConnectionManager for direct communication

    // Manages direct communication. Input should be the UUID of your pack, or some other unique id
    const manager = new IPC.ConnectionManager('UUID')
    
    // ConnectionManager handles listening to channels
    manager.on('channel', args => {}) 
    manager.once('channel', args => {})
    manager.handle('channel', args => {})
    
    // Connect to other packs using their unique ID
    manager.connect('Other UUID').then(connection => {
      // Connections handle sending
      connection.send('channel', 'test_message')
      connection.invoke('channel').then(result => {})
    })

    Example

    // PACK 1
    const manager = new IPC.ConnectionManager('5a456e5c-b064-4ea4-9626-8bb59b7dec0c')
    
    // Connect to Pack 2
    manager.connect('6aad99ef-937d-49ac-a7c2-6d5528eda113').then(() => {
        console.warn('Connected to Pack 2')
    })
    
    // Listen for messages on direct channel
    manager.on('direct_message', message => {
        console.warn(message)
    })
    // PACK 2
    const manager = new IPC.ConnectionManager('6aad99ef-937d-49ac-a7c2-6d5528eda113')
    
    // Connect to Pack 1
    manager.connect('5a456e5c-b064-4ea4-9626-8bb59b7dec0c').then(connection => {
        console.warn('Connected to Pack 1')
    
        // Send a direct message to Pack 1
        connection.send('direct_message', 'Direct Message from Pack 2 to Pack 1')
    })

Full Changelog: v1.3.1...v1.4.0