mpdws

websocket "now playing:" broadcast mpd hook
Download | Log | Files | Refs | README | LICENSE

main.c (672B)


      1 #include "mpdws.h"
      2 #include <stdio.h>
      3 #ifdef __OpenBSD__
      4 #include <unistd.h>
      5 #endif
      6 
      7 int main() {
      8 #ifdef __OpenBSD__
      9   if (pledge("rpath inet stdio", NULL) == -1) {
     10     perror("pledge");
     11     return 1;
     12   }
     13 #endif
     14 
     15   struct mpd_ws_server server;
     16 
     17   printf("MPD WebSocket Bridge\n");
     18   printf("Connecting to MPD at %s:%d\n", MPD_HOST, MPD_PORT);
     19   printf("WebSocket server on port %d\n", WEBSOCKET_PORT);
     20 
     21   /* Initialize server */
     22   if (mpd_ws_init(&server) < 0) {
     23     fprintf(stderr, "Failed to initialize server\n");
     24     return 1;
     25   }
     26 
     27   /* Run main loop */
     28   mpd_ws_run(&server);
     29 
     30   /* Cleanup */
     31   mpd_ws_cleanup(&server);
     32 
     33   printf("Server shut down\n");
     34   return 0;
     35 }