Custom Event-based WebSockets Framework for Building Real-time Apps on Deno

Dropper

Dropper is a custom Event-driven WebSocket framework for Deno, using the deno-std ws module as base.

Send and receive notifications, messages, updates and any data, all in real-time with custom events and methods served on your own, Dropper is Open Source, self-served and FREE forever!

What can I do with Dropper?

Since Dropper is a WebSocket solution for delivering messages between servers and clients in real-time, it’s Side by Side APIs are designed to handle custom events sent by the application peers, you can work with the structured event handlers that allows to send and receive classified data in a woshhh.

Importing

Server:

import { Server } from 'https://deno.land/x/dropper@1.8.0/src/mod.ts';
//or
import { Server } from 'https://x.nest.land/dropper@1.8.0/src/mod.ts'

Deno client:

You can import the client directly on your Deno app.

import Dropper from 'https://deno.land/x/dropper@1.8.0/src/mod.ts';
//or
import Dropper from 'https://x.nest.land/dropper@1.8.0/src/mod.ts'

Browser client

You can import this client on the browser in a module script.

import Dropper from 'https://deno.land/x/dropper@1.8.0/dist/clients/dropper.browser.js';
//or
import Dropper from 'https://x.nest.land/dropper@1.8.0/dist/clients/dropper.browser.js'

Usage

By default, it exports two instances of WebSocket. The API is very similar to the websockets API for browsers, but based on custom events.

Server:

The server waits for socket connections using the global event connection. This event gets the new connected socket on its callback. This socket represents a client so the API is the same as in the client side.

Stand alone server

Dropper is stand alone by default, which means tha you don’t need to provide an http server, when you create a dropper it serves by default on port 8080.

This is useful whe you are creating an app without a server side.

const options;

const dropper = new Server(options); // Creates a default server on port 8080

dropper.on('connection', socket => { // W
  socket.send('pizza', 'I sent you a pizza!')
  socket.on('thanks', data => {
    console.log(data) // => Thanks btw
  })
})

// Listening for global events

dropper.on('thanks', data => {
  console.log(data) // => Thanks btw
})

Middleware server

You can also use Dropper with a server/framework setup since it handles each request separately with the method Dropper.handle(req)

  • Using a framework like opine:
import { opine } from 'https://opinesource/mod.ts'
const app = opine();
import { Server as Dropper } from '...'

const dropper = new Dropper({
  serve: false // Important
})

app.use('/dropper' (req) => dropper.handle(req)); // Don't respond or call next, just use the request.

app.get('/', (req, res) => {
  //...foo
})

dropper.on('connection', socket => {
  ..foo
})

app.listen(3000)
  • Using the std http server:
import { serve } from 'https://serverhttpsouce/mod.ts'
import { Server as Dropper } from '...'

const server = serve('localhost:3000')

const dropper = new Dropper({
  serve: false // Important
})

dropper.on('connection', socket => {
  ..foo
})

for await (const req of server) {
  if (req.url === '/dropper') {
    dropper.handle(req);
  } else {
    // return static content, etc
  }
}

Please note that we use the /dropper endpoint on both of the examples. This is because we don’t want to touch any usable endpoint, you can use whatever you want as endpoint, but you have to provide it in the Dropper client config object which is by default /dropper.

Options (optional)

  • host: The host you want to use if the serve is true.
    • Default: ‘localhost’,
  • port: The host you want to use if the serve is true
    • Default: 8080,
  • interval: The ping interval in ms.
    • Default: 3000
  • serve: Set false if you don’t want to serve Dropper (stand alone)
    • Default: true

API

Methods:

  • Dropper.on - Listen for the server events.

    The on method receives two arguments:

    • event - The event name
    • callback - Callback function to get the new connected socket instance if the event is connection or the event data if the event is any.
  • Dropper.send - Send global data to all connected sockets

    The send method receive two arguments.

    • Argument1: event | data - This argument changes to data if the data argument is not provided, by default it is the event name.
    • data (optional) - This is the data to be sent.
  • Dropper.handle - Handles the request to accept WebSockets

    The handle method receive one arguments.

    • request - This is a deno std http request object of the type ServerRequest.

Properties:

  • Dropper.clients - List of all connected clients instances.

Sending data to clients

You can send data to clients in three ways:

  • Just to the current socket:
dropper.on('connection', socket => {
  socket.send('hello')
})

No one will receive this data except the current socket.

  • To all sockets but the current one:
dropper.on('connection', socket => {
  socket.broadcast('hello')
})

All clients will receive the data except the current client.

  • To all connected sockets:
dropper.send('hello')

All clients will receive the data .

Listening for client events

  • All events from current socket or globally:

The event name for listening to all events is _all_

dropper.on('connection', socket => {
  socket.on('_all_', data => { // Listen for all events from this socket

  })
})

// or globally

dropper.on('_all_', ...foo)
  • Custom events from current socket or globally:
...
socket.on('custom_event', ...foo) // Catch event just from the socket
...

dropper.on('custom_event', ...foo) // Catch event from all sockets
  • No named events from current socket or globally:

If the client send a no named event (client_side_dropper.send('no named')), you can listen to it with the event name message

...
socket.on('message', ...foo) // Catch no named event just from the socket
...

dropper.on('message', ...foo) // Catch no named event from all sockets

Handling disconnections from server

You can handle disconnections on two scopes:

From socket:

Handling disconnects from sockets only works if the socket is manually disconnected. It will not work if the client loses connection. The callback receives the same two arguments as in the client API (bellow).

dropper.on('connection', socket => {
  socket.on('close', (code, reason) => {
    //...foo
  })
})

From global

Handling global disconnects will listen to all clients that disconnect manually and also those that lose connection. The callback receives the same two arguments as in the client API (bellow) plus the disconnected socket as in the connection event.

dropper.on('disconnection', (code, reason, socket) => {
  //...foo
})

Reserved event senders

This is a list with the events you shouldn’t play with:

  • connection - The connection event sending is reserved for handling peer connection on server.
  • error - The error event sending is reserved for handling connection issues.
  • disconnection - The disconnection event sending is reserved for handling peer disconnection on server.

Client

The client API connects to a server and it is a socket instance, so it has the same methods as the socket above.

const dropper = new Dropper(); // Connect the client on port 8080
dropper.on('pizza', function(data){
  console.log(data) // => I sent you a pizza!
  dropper.send('thanks', 'Thanks btw');
  dropper.close() // Closes the connection manually
});

dropper.on('close' => console.log('done'))

Options (optional)

  • endpoint - This is the endpoint that the server uses to handle wbsockets.
    • Default: /dropper

API

Methods:

  • close - Closes the connection.

    The close method receives two optional arguments:

    • code - Connection close code number
    • reason - A reason message for the close event.
  • broadcast - Send the data to the server to be broadcasted to all peers but this (Meant to be used on server-side).

    The broadcast method receive two arguments.

    • Argument1: event | data - This argument changes to data if the data argument is not provided, by default it is the event name.
    • data (optional) - This is the data to be sent.
  • on - Listen for the client events.

    The on method receives two arguments:

    • event - The event name
    • callback - Callback function to get the event data.
  • send - Send the data to the server.

    The send method receive same arguments as the broadcast method.

    Properties:

    • Dropper.uuid - The id of the client.
    • Dropper._socket - This is the WebSocket instance itself.
    • Dropper.uri - The WebSockets connection uri.

Sending data to server

  • Named event

This is pushing a custom event to the server

dropper.send('pizza', 'this is a pizza')
  • No named event

This is pushing a no named event to the server

dropper.send('this is a pizza')

Listening for server events

  • Named event

This is listening a custom event from the server

dropper.on('pizza', data => {
  ...foo
})
  • No named event

This is listening a no named event from the server

dropper.on('message', data => {
  ...foo
})

Handling disconnections

  • Handle own disconnection

To handle the socket disconnection you can use the close event. It only listen when the sockets disconnects itself.

dropper.on('close', (code, reason) => {
  ...foo
})
  • Handle other peers disconnection

When a peer disconnects the server trigger the disconnection event that is useful for listening when other peers leave. It provides de uuid of the leaving socket.

dropper.on('disconnection', uuid => {
  ...foo
})

Reserved event senders

This is a list with the events you shouldn’t play with:

  • _binary_ - The binary event sending is reserved for handling Uint8Array data.
  • error - The error event sending is reserved for handling connection issues.
  • _all_ - The message event is the global event for listening to data.
  • _ping_ - The ping event is a websockets connection handler.
  • _pong_ - The pong event is a websockets connection handler.
  • _broadcast_ - The broadcast event is an internal event for transport data to all users but the current one.

Event collision warning

All the Dropper internal events has as prefix and suffix _. For example this is an internal event: _ping_, This is for preventing event collisions.

The documentation is WIP right now

By now, you can find detailed code in the examples folder.

📝 Roadmap

  • Channels support
  • ✔️ Rename the message event to _all_
  • Auto reconnect
  • ✔️ Improve documentation
  • Website
  • ✔️ Prevent using internal events
  • ✔️ Handle forced client disconnection

👊 Support this project by donating on:

  • Paypal.
  • BTC address: 39ik7oyYvmiMeTXTscY3bb9rUFMHdjf5pd

Download Details:

Author: denyncrawford

Source Code: https://github.com/denyncrawford/dropper-deno

#deno #nodejs #node

What is GEEK

Buddha Community

Custom Event-based WebSockets Framework for Building Real-time Apps on Deno

How much does it cost to develop an app for the event planning business?

Event planning & management app is the generic term for a wide range of mobile app products that are used in the management of professional and academic conferences, trade exhibitions, conventions, and events such as Continuing Professional Development meetings.

Development Cost to build an Event Planning & Management App:

Based on the number of hours invested, features, and technologies involved, you can determine a rough estimate of Event Planning or Management app development cost. Cost depends on various factors such as follows.

• Basic & Advance Features

• Technology used

• Chosen Platform (iOS & Android)

• The Location of the app development center

• Mobile App complexity

• Numbers of hours invested in Project

The cost to create such an app can be as high as the number of integrated technologies. However, an app with basic features is certain to cost somewhere around $10,000 to $35,000 for single platforms (Android or iOS). If you want to make an app for various platforms then the cost will be vary based on features, location, development team, etc factors.

Best Event Planning & Management App Development Company:

Event Management apps streamline the entry process for events. Save your precious time for a smooth experience and devote time for more significant activities such as increasing revenue with a mobile app from AppClues Infotech, a top Events & Exhibitions App Development Company based in the USA and offer the best services across the world.

Save your time and money with their cost-effective mobile apps to easily collaborate with the participants of the events. Real-time chats help to carry out video conferencing with both the participants and the employees as well. Their mobile apps increase the efficiency of multiple events by sending important messages to the participants with a single click.

Offering services that make events successful:

  • Corporate events
  • Conferences
  • Trade shows
  • Sports and entertainment
  • Custom event schedule app development

Incorporate features that elevate experiences

  • Event creation
  • Event search
  • Event calendar
  • Ticket booking
  • Photo sharing
  • GPS
  • Push notification
  • Chatbot
  • Messaging
  • In-app payment
  • News & social feeds
  • In-app analytics

#how to develop an event app #event management app development company #custom event management app development #how to build an event planning app #develop a mobile app for events #cost to build a event management app

Custom Mobile App Development Services in USA

Want to build a custom mobile app for your business or startup? We at AppClues Infotech, provide the best custom mobile app development services in USA. We have highly skilled & creative team of custom mobile app designers and developers that will help to make a perfect mobile app with the latest features & functionalities.

However big or small your app development needs, we’ll build you a finest & effective mobile app that’s tailored specifically to your business needs.

Our Custom Mobile App Development Services:
• Android & iOS App Development
• Cross-Platform & Hybrid App Development
• Enterprise Mobility Solutions
• Mobile Commerce App Development
• Mobile Wallet App Development
• Wearable App Development
• UI/UX Design
• Mobile App Consulting

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#custom mobile app development company in usa #hire custom mobile app developers #top custom app development company in usa #how to build custom mobile app #custom mobile app development #custom mobile app development services in usa

Event Planning App Development

A manual search for ticket holders in an event leads to long queues and a delay in start time. This affects the credibility of the event management company. With an event management app, you can have seamless interactions; you can effortlessly communicate with event attendees. Also, event apps facilitate enhanced networking at events

Do you wish to have an event management app of your own?

DataIT Solutions are here to serve you with the best Event booking application for Android and iPhone. Having years of in-depth experience in mobile application development, we have been delivering the top class solutions for app development as per user prerequisites each time. Our mobile developers having all the skills to provide you a customized event application and can work on any kind of Mobile App Development for Event Booking.

What can you expect while you work with us for Mobile Event Mobile App Development?

  • Experienced Team of Web and Graphics Designers
  • Event App Development Team with rich exposure to Event Planning and Event Management App for iOS, Android, and other platforms
  • Consultative and Agile approach to Project Management
  • Cost-Effective and Custom Business Model to meet your Requirements
  • Effective tools of communication providing you detailed updates on every stage of your Project by your convenient mode of communication at your preferred time.

Excited to know more about the scope of your project? Send us an email for a free quote on Event Mobile App Development for your requirement to sales@dataitsolutions.com.

#event planning app development #event planning app developer #event app developer #event app development #event app #app development

Best Event Management Mobile App Development Company

Have any Idea of App Development for Event Management and Planning? Then you are at the right place. AppClues Infotech has the best-skilled developers specialize in creating custom event management apps that will allow you to maintain all your events with a single app.

We can help with developing the following types of event apps:

• Social Event Planning App
• Event Management App
• App for Organizing Conferences
• Event & Exhibition Organization App
• Event Registration App
• Event Booking App

For more info:
Call: +1-978-309-9910
Email: info@appcluesinfotech.com

#event management app development company #how to build an event planning app #custom event management app development #make an event management app #create an event planning app

Best Android Mobile App Development Frameworks

Are you looking for the best Android app development frameworks? Get the best Android app development frameworks that help to build the top-notch Android mobile app.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#best android mobile app development frameworks #top mobile app development frameworks #android app development frameworks #top frameworks for android app development #most popular android app development frameworks #app development frameworks