GithubHelp home page GithubHelp logo

oc-websockets's Introduction

October WebSockets

Add real-time features to your OctoberCMS project.

Usage

Start the server

php artisan websockets:run

You can specify a --port if you want to, default is 8080.

Attach the component

Add the client component to your page/layout. You can set an uri property if you are running on a different port. Default is ws://localhost:8080/.

[websocket]
==

The API

It uses an AJAX framework-like API, is familiar for OctoberCMS developers

data-websocket-event="name"

It fires up send() method with the specified event name.

data-websocket-oneventname="console.log(event)"

It evals the informed script, just like AJAX framework with a data argument.

You are ready to rock on sockets. Build a chat app!

Don't forget to add jQuery and {% scripts %} placeholder.

url = "websockets"
[websocket]
==
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Web Sockets</title>
    </head>
    <body>
        <ul data-websocket-onmessage="$(this).append('<li>'+event.payload.text+'</li>')"></ul>
        
        <form role="form" data-websocket-event="message">
            <input type="text" name="text">
            <button type="submit">Send</button>
        </form>
        
        <script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
        {% scripts %}
    </body>
</html>

oc-websockets's People

Contributors

leocavalcante avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

oc-websockets's Issues

Error on "composer require cboden/ratchet"

I'm trying out your plugin on Homestead but I'm getting stuck already at composer require cboden/ratchet. The result I get is:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package cboden/ratchet ^0.3.5 is satisfiable by cboden/ratchet[v0.3.5, v0.3.6] but these conflict with your requirements or minimum-stability.

And I don't know what to do. If I go to my plugin folder, initiate composer and run composer require cboden/ratchet is seems to work. But not when I try to add it to the October CMS composer file. How do I solve this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.