Developer Documentation

Client Connection Guide

Learn how to configure your frontend and backend applications to broadcast and listen for sub-millisecond events with OsciWave.

1. Quickstart & API Credentials

To connect to OsciWave, obtain your credentials from your account dashboard:

Credential Field Example Value
App ID ow_app_849204
App Key ow_key_7392019482736451
App Secret sk_sec_9938201928475612
WebSocket Host ws.osciwave.test:8080

2. Connecting via Laravel Echo

OsciWave is fully compatible with `laravel-echo` and `pusher-js`. Install the dependencies in your frontend project:

npm install --save laravel-echo pusher-js

Configure `resources/js/bootstrap.js` with your OsciWave socket parameters:

import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

window.Pusher = Pusher;

window.Echo = new Echo({
    broadcaster: 'reverb',
    key: import.meta.env.VITE_OSCIWAVE_APP_KEY,
    wsHost: import.meta.env.VITE_OSCIWAVE_HOST ?? 'ws.osciwave.test',
    wsPort: import.meta.env.VITE_OSCIWAVE_PORT ?? 8080,
    wssPort: import.meta.env.VITE_OSCIWAVE_PORT ?? 8080,
    forceTLS: false,
    enabledTransports: ['ws', 'wss'],
});

// Listening for real-time events
window.Echo.channel('orders')
    .listen('OrderProcessed', (e) => {
        console.log('Order event received:', e);
    });

3. Connecting via Standard Pusher JS

You can also connect directly using the vanilla `pusher-js` client library without Laravel Echo:

import Pusher from 'pusher-js';

const pusher = new Pusher('ow_key_7392019482736451', {
    wsHost: 'ws.osciwave.test',
    wsPort: 8080,
    forceTLS: false,
    disableStats: true,
    enabledTransports: ['ws', 'wss']
});

const channel = pusher.subscribe('osciwave-public');
channel.bind('ping', function(data) {
    alert(JSON.stringify(data));
});

4. REST Broadcast API Endpoint

To publish events from any backend language (PHP, Node.js, Python, Go, Ruby), send an HTTP POST request to the REST broadcast endpoint:

POST /api/apps/{app_id}/events

Example `curl` payload request:

curl -X POST "http://127.0.0.1:8000/api/apps/ow_app_849204/events" \
  -H "Content-Type: application/json" \
  -H "X-OsciWave-Key: ow_key_7392019482736451" \
  -d '{
    "channel": "orders",
    "name": "OrderProcessed",
    "data": {
      "order_id": 1042,
      "status": "completed",
      "amount": 99.00
    }
  }'

5. Private & Presence Channel Authorization

Private channels require an authorized subscription payload authenticated by an HMAC signature generated by your backend application.

window.Echo.private(`user.${userId}`)
    .listen('NotificationSent', (e) => {
        console.log(e.notification);
    });