Skip to content

Commit

Permalink
Add LIIIIIVVVEEEE comment stream
Browse files Browse the repository at this point in the history
  • Loading branch information
typcn committed May 17, 2015
1 parent 5bb904b commit e831757
Show file tree
Hide file tree
Showing 10 changed files with 401 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bilibili.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
FD2BD5631AD11319001A7E16 /* playLocalFile.m in Sources */ = {isa = PBXBuildFile; fileRef = FD2BD5621AD11319001A7E16 /* playLocalFile.m */; };
FD2BD56E1AD15AE0001A7E16 /* libmediainfo.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FD2BD56D1AD15AE0001A7E16 /* libmediainfo.0.dylib */; };
FD2BD56F1AD15AF9001A7E16 /* libmediainfo.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD2BD56D1AD15AE0001A7E16 /* libmediainfo.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
FD33F5B91B085D3100DF4C78 /* LiveChat.m in Sources */ = {isa = PBXBuildFile; fileRef = FD33F5B81B085D3100DF4C78 /* LiveChat.m */; };
FD33F5C61B08A5A500DF4C78 /* Socket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD33F5C41B08A5A500DF4C78 /* Socket.cpp */; };
FD471B4F1AC8FF3C00A2A727 /* PlayerView.mm in Sources */ = {isa = PBXBuildFile; fileRef = FD471B4D1AC8FF3C00A2A727 /* PlayerView.mm */; };
FD471B521AC904CB00A2A727 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD471B511AC904CB00A2A727 /* CoreAudio.framework */; };
FD476C6A1AD2086900584EFE /* Settings.m in Sources */ = {isa = PBXBuildFile; fileRef = FD476C691AD2086900584EFE /* Settings.m */; };
Expand Down Expand Up @@ -76,6 +78,7 @@
FD6102621AD7CC020013119A /* inject.js in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD61025B1AD7CBA20013119A /* inject.js */; };
FD6102631AD7CC020013119A /* webui.html in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD61025D1AD7CBC10013119A /* webui.html */; };
FD6102641AD7CC020013119A /* webui.css in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD6102601AD7CBF10013119A /* webui.css */; };
FD855FB01B07D884004A1610 /* BilibiliSocketClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = FD855FAF1B07D884004A1610 /* BilibiliSocketClient.mm */; };
FD8CEDEF1AD2499B0092452F /* CommentBlockSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = FD8CEDEE1AD2499B0092452F /* CommentBlockSettings.m */; };
FD8CEDF21AD24A290092452F /* KeywordBlockSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = FD8CEDF11AD24A290092452F /* KeywordBlockSettings.m */; };
FDA775DE1AD93D1800426483 /* libaria2.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA775DD1AD93D1800426483 /* libaria2.0.dylib */; };
Expand Down Expand Up @@ -188,6 +191,11 @@
FD2BD5621AD11319001A7E16 /* playLocalFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = playLocalFile.m; sourceTree = "<group>"; };
FD2BD56D1AD15AE0001A7E16 /* libmediainfo.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libmediainfo.0.dylib; path = bilibili/libs/libmediainfo.0.dylib; sourceTree = "<group>"; };
FD2BD5701AD15BCA001A7E16 /* MediaInfoDLL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MediaInfoDLL.h; path = bilibili/headers/MediaInfoDLL/MediaInfoDLL.h; sourceTree = "<group>"; };
FD33F5B31B085BEC00DF4C78 /* BilibiliSocketClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BilibiliSocketClient.h; sourceTree = "<group>"; };
FD33F5B71B085D3100DF4C78 /* LiveChat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiveChat.h; sourceTree = "<group>"; };
FD33F5B81B085D3100DF4C78 /* LiveChat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LiveChat.m; sourceTree = "<group>"; };
FD33F5C41B08A5A500DF4C78 /* Socket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Socket.cpp; sourceTree = "<group>"; };
FD33F5C51B08A5A500DF4C78 /* Socket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Socket.hpp; sourceTree = "<group>"; };
FD471B4C1AC8FF3C00A2A727 /* PlayerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayerView.h; sourceTree = "<group>"; };
FD471B4D1AC8FF3C00A2A727 /* PlayerView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlayerView.mm; sourceTree = "<group>"; };
FD471B511AC904CB00A2A727 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -227,6 +235,7 @@
FD61025B1AD7CBA20013119A /* inject.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = inject.js; path = WebPages/inject.js; sourceTree = "<group>"; };
FD61025D1AD7CBC10013119A /* webui.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = webui.html; path = WebPages/webui.html; sourceTree = "<group>"; };
FD6102601AD7CBF10013119A /* webui.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = webui.css; path = WebPages/webui.css; sourceTree = "<group>"; };
FD855FAF1B07D884004A1610 /* BilibiliSocketClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BilibiliSocketClient.mm; sourceTree = "<group>"; };
FD8CEDED1AD2499B0092452F /* CommentBlockSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentBlockSettings.h; sourceTree = "<group>"; };
FD8CEDEE1AD2499B0092452F /* CommentBlockSettings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentBlockSettings.m; sourceTree = "<group>"; };
FD8CEDF01AD24A290092452F /* KeywordBlockSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeywordBlockSettings.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -326,6 +335,7 @@
FD076C521AC8CBBB00C893FA /* bilibili */ = {
isa = PBXGroup;
children = (
FD855FAE1B07D86C004A1610 /* RealTimeComments */,
FDA775E81AD93ED600426483 /* downloadManager */,
FD61025A1AD7CB760013119A /* WebPages */,
FD476C701AD22AEC00584EFE /* GUI */,
Expand Down Expand Up @@ -477,6 +487,8 @@
FD471B4D1AC8FF3C00A2A727 /* PlayerView.mm */,
FD4D376C1ACEFD7B0022ABF3 /* PostComment.h */,
FD4D376D1ACEFD7B0022ABF3 /* PostComment.m */,
FD33F5B71B085D3100DF4C78 /* LiveChat.h */,
FD33F5B81B085D3100DF4C78 /* LiveChat.m */,
);
name = "Player View";
sourceTree = "<group>";
Expand Down Expand Up @@ -508,6 +520,17 @@
name = WebPages;
sourceTree = "<group>";
};
FD855FAE1B07D86C004A1610 /* RealTimeComments */ = {
isa = PBXGroup;
children = (
FD33F5B31B085BEC00DF4C78 /* BilibiliSocketClient.h */,
FD855FAF1B07D884004A1610 /* BilibiliSocketClient.mm */,
FD33F5C41B08A5A500DF4C78 /* Socket.cpp */,
FD33F5C51B08A5A500DF4C78 /* Socket.hpp */,
);
name = RealTimeComments;
sourceTree = "<group>";
};
FD8CEDEC1AD249540092452F /* Settings View */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -694,19 +717,22 @@
buildActionMask = 2147483647;
files = (
FD076C5C1AC8CBBB00C893FA /* ViewController.mm in Sources */,
FD855FB01B07D884004A1610 /* BilibiliSocketClient.mm in Sources */,
FD076C591AC8CBBB00C893FA /* main.m in Sources */,
FD8CEDF21AD24A290092452F /* KeywordBlockSettings.m in Sources */,
FD476C6A1AD2086900584EFE /* Settings.m in Sources */,
FD076C571AC8CBBB00C893FA /* AppDelegate.mm in Sources */,
FD2BD5631AD11319001A7E16 /* playLocalFile.m in Sources */,
FDFC8AB91AD5745B000AFDB2 /* danmaku2ass.cpp in Sources */,
FD4D376E1ACEFD7B0022ABF3 /* PostComment.m in Sources */,
FD33F5B91B085D3100DF4C78 /* LiveChat.m in Sources */,
FDA775E61AD93ECA00426483 /* DownloadManager.m in Sources */,
FDFC8AB81AD5745B000AFDB2 /* AssClass.cpp in Sources */,
FD471B4F1AC8FF3C00A2A727 /* PlayerView.mm in Sources */,
FDAF8BAA1ACA5A3100C0C55D /* AboutView.m in Sources */,
FDAF8B9E1ACA4C1C00C0C55D /* ISSoundAdditions.m in Sources */,
FD8CEDEF1AD2499B0092452F /* CommentBlockSettings.m in Sources */,
FD33F5C61B08A5A500DF4C78 /* Socket.cpp in Sources */,
FD476C731AD22B1F00584EFE /* CommentFilter.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
62 changes: 62 additions & 0 deletions bilibili/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,68 @@
</objects>
<point key="canvasLocation" x="-465" y="508.5"/>
</scene>
<!--Window Controller-->
<scene sceneID="PkE-Ql-sEX">
<objects>
<windowController storyboardIdentifier="LiveChatWindow" id="ffQ-wz-5FH" sceneMemberID="viewController">
<window key="window" title="实时弹幕" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="i8z-Ck-rGI">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="425" y="313" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1057"/>
</window>
<connections>
<segue destination="rag-YS-WW4" kind="relationship" relationship="window.shadowedContentViewController" id="Mel-oP-O06"/>
</connections>
</windowController>
<customObject id="gpp-QG-vUa" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="58" y="511"/>
</scene>
<!--Live Chat-->
<scene sceneID="bxO-Km-cPj">
<objects>
<viewController id="rag-YS-WW4" customClass="LiveChat" sceneMemberID="viewController">
<view key="view" id="kPu-6a-C1j">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="eor-Rw-gdL">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" id="Rhz-Ly-fC1">
<rect key="frame" x="1" y="1" width="463" height="268"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" usesFontPanel="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" smartInsertDelete="YES" id="Yey-g8-OWP">
<rect key="frame" x="0.0" y="0.0" width="223" height="133"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="463" height="268"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="463" height="268"/>
<size key="maxSize" width="463" height="10000000"/>
</textView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="76T-FJ-sTU">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="Ft0-cT-2BV">
<rect key="frame" x="224" y="1" width="15" height="133"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
</view>
</viewController>
<customObject id="MvD-Kh-aNt" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="58" y="969"/>
</scene>
<!--Post Comment Window Controller-->
<scene sceneID="bs0-gn-v1d">
<objects>
Expand Down
20 changes: 20 additions & 0 deletions bilibili/BilibiliSocketClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// BilibiliSocketClient.h
// bilibili
//
// Created by TYPCN on 2015/5/17.
// Copyright (c) 2015 TYPCN. All rights reserved.
//

#ifndef bilibili_BilibiliSocketClient_h
#define bilibili_BilibiliSocketClient_h

#import <Foundation/Foundation.h>

@interface LiveSocket : NSObject

- (bool)ConnectToTheFuckingFlashSocketServer: (int)roomid;

@end

#endif
52 changes: 52 additions & 0 deletions bilibili/BilibiliSocketClient.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// SocketClient.m
// bilibili
//
// Created by TYPCN on 2015/5/17.
// Copyright (c) 2015 TYPCN. All rights reserved.
//

#import "BilibiliSocketClient.h"

#include "Socket.hpp"

@implementation LiveSocket{
tcp_client c;
}

- (bool)ConnectToTheFuckingFlashSocketServer: (int)roomid{
if(!c.conn("livecmt.bilibili.com" , 88)){
return false;
}

NSString *initStr = [NSString stringWithFormat:@"0101000c0000%04x00000000",roomid];
NSData *data = [self dataFromHexString:initStr];
c.send_data([data bytes], (int)[data length]);
while(true){
std::string str = c.receive(1024);
if(str.length() > 0){
NSLog(@"Data: %s",str.c_str());
}
}
return true;
}

- (NSData *)dataFromHexString:(NSString *)str {
const char *chars = [str UTF8String];
int i = 0, len = (int)str.length;

NSMutableData *data = [NSMutableData dataWithCapacity:len / 2];
char byteChars[3] = {'\0','\0','\0'};
unsigned long wholeByte;

while (i < len) {
byteChars[0] = chars[i++];
byteChars[1] = chars[i++];
wholeByte = strtoul(byteChars, NULL, 16);
[data appendBytes:&wholeByte length:1];
}

return data;
}

@end
13 changes: 13 additions & 0 deletions bilibili/LiveChat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// LiveChat.h
// bilibili
//
// Created by TYPCN on 2015/5/17.
// Copyright (c) 2015 TYPCN. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface LiveChat : NSViewController

@end
27 changes: 27 additions & 0 deletions bilibili/LiveChat.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// LiveChat.m
// bilibili
//
// Created by TYPCN on 2015/5/17.
// Copyright (c) 2015 TYPCN. All rights reserved.
//

#import "LiveChat.h"
#import "BilibiliSocketClient.h"

extern NSString *vCID;

@interface LiveChat ()

@end

@implementation LiveChat

- (void)viewDidLoad {
[super viewDidLoad];
LiveSocket *socket = [[LiveSocket alloc] init];

[socket ConnectToTheFuckingFlashSocketServer:[vCID intValue]];
}

@end
Loading

0 comments on commit e831757

Please sign in to comment.