Skip to content

bilgi42/represence-vscode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Represence Code Extension

The VS Code extension for Represence - provides presence detection by sharing file information via WebSocket.

๐Ÿš€ Quick Start

Installation

Option 1: Install from VSIX file

  1. Download the represence-vscode-0.0.2.vsix file
  2. Open VS Code
  3. Go to Extensions view (Ctrl+Shift+X or Cmd+Shift+X)
  4. Click the "..." menu and select "Install from VSIX..."
  5. Select the downloaded .vsix file

Option 2: Command line installation

code --install-extension represence-vscode-0.0.2.vsix

First Time Setup

  1. After installation, the extension automatically starts a WebSocket server on port 3847
  2. You'll see a notification: "Represence WebSocket server started on port 3847"
  3. The extension is now broadcasting your current file information!

๐Ÿ“ก How It Works

The extension creates a WebSocket server that broadcasts information about your currently active file to any connected clients. This is perfect for:

  • Live coding sessions - Show others what file you're working on
  • Presence detection - Let external applications know your current context
  • Development tools - Integration with custom dashboards or monitoring systems

What Information is Shared?

The extension broadcasts a JSON object with:

{
  "filename": "example.js",
  "extension": ".js", 
  "path": "/full/path/to/example.js",
  "language": "javascript",
  "lineCount": 42,
  "wordCount": 156,
  "timestamp": "2024-01-01T12:00:00.000Z"
}

๐Ÿ”ง Configuration

Settings

Access settings via:

  • Command Palette: Ctrl+Shift+P โ†’ "Configure Represence Extension"
  • Or go to: File โ†’ Preferences โ†’ Settings โ†’ Search for "fileInfo"

Available Settings:

Setting Default Description
fileInfo.websocketPort 3847 WebSocket server port (1024-65535)
fileInfo.enableLogging false Enable verbose logging in developer console

Environment Variable Override

Environment variable support has been removed. Use VS Code settings instead.

Priority order: VS Code Setting > Default (3847)

๐ŸŽฎ Usage

Commands

Access these via Command Palette (Ctrl+Shift+P or Cmd+Shift+P):

Command Description
Show Current File Info Display current file information in a popup
Configure Represence Extension Open extension settings

Real-time Updates

The extension automatically sends updates when:

  • โœ… You switch to a different file
  • โœ… You make changes to the current file
  • โœ… You open/close files

๐Ÿ”Œ Connecting to the WebSocket

JavaScript/Node.js Example

const WebSocket = require('ws');

const ws = new WebSocket('ws://localhost:3847');

ws.on('open', () => {
    console.log('Connected to Represence');
});

ws.on('message', (data) => {
    const fileInfo = JSON.parse(data);
    console.log('Current file:', fileInfo.filename);
    console.log('Language:', fileInfo.language);
    console.log('Lines:', fileInfo.lineCount);
});

Python Example

import websocket
import json

def on_message(ws, message):
    file_info = json.loads(message)
    print(f"Current file: {file_info['filename']}")
    print(f"Language: {file_info['language']}")
    print(f"Lines: {file_info['lineCount']}")

def on_open(ws):
    print("Connected to Represence")

ws = websocket.WebSocketApp("ws://localhost:3847",
                          on_message=on_message,
                          on_open=on_open)
ws.run_forever()

๐Ÿ› ๏ธ Troubleshooting

Port Already in Use

If you see "Failed to start WebSocket server on port 3847. Port might be in use":

  1. Change the port: Go to settings and change fileInfo.websocketPort to a different number
  2. Kill the process: Find what's using the port:
    # Linux/Mac
    lsof -i :3847
    # Windows
    netstat -ano | findstr :3847

Extension Not Working

  1. Check developer console: Help โ†’ Toggle Developer Tools โ†’ Console tab
  2. Enable logging: Set fileInfo.enableLogging to true in settings
  3. Reload VS Code: Command Palette โ†’ "Developer: Reload Window"

Connection Issues

  • Ensure your firewall allows connections on the configured port
  • Test the WebSocket connection with a simple client (see examples above)
  • Check that no other application is using the same port

๐Ÿ”„ Development

Building from Source

git clone <repository-url>
cd represence-vscode
npm install
npm run compile

Packaging

npm install -g vsce
vsce package

Testing

  1. Press F5 in VS Code to launch Extension Development Host
  2. Test the extension in the new window
  3. Check the debug console for logs

๐Ÿ“„ License

This extension is open source. Check the repository for license details.

๐Ÿค Contributing

Found a bug or want to add a feature? Contributions are welcome!


Happy coding with Represence! ๐ŸŽ‰

About

Represence's VSCode extension

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published