Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chat_webview
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abookCommunication
chat_webview
Commits
b8c0ce73
Commit
b8c0ce73
authored
Apr 07, 2021
by
Takatoshi Miura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iosローカルdb連携中
parent
fc5eb4c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
29 deletions
+22
-29
public_new/js/chat-db.js
+22
-29
No files found.
public_new/js/chat-db.js
View file @
b8c0ce73
...
...
@@ -2,20 +2,6 @@
var
CHAT_DB
=
{};
// ios用
var
iosKey
=
"objc-processing"
;
function
watchValue
(
obj
,
propName
,
func
)
{
let
value
=
obj
[
propName
];
Object
.
defineProperty
(
obj
,
propName
,
{
get
:
()
=>
value
,
set
:
newValue
=>
{
const
oldValue
=
value
;
value
=
newValue
;
func
(
oldValue
,
newValue
);
},
configurable
:
true
});
}
const
iosData
=
{
iosRoomList
:
""
,
iosMyInfo
:
""
,
...
...
@@ -34,16 +20,19 @@ const iosData = {
iosArchiveDetail
:
""
};
function
onChange
(
v1
,
v2
)
{
console
.
log
(
v1
);
console
.
log
(
' =>'
,
v2
);
console
.
log
(
''
);
var
webClient
=
{
id
:
1
,
handlers
:
{},
};
Object
.
getOwnPropertyNames
(
iosData
).
forEach
(
propName
=>
watchValue
(
iosData
,
propName
,
onChange
));
iosData
.
iosRoomList
=
"roomList"
;
webClient
.
onMessageReceive
=
(
handle
,
error
,
data
)
=>
{
if
(
error
&&
webClient
.
handlers
[
handle
].
reject
)
{
webClient
.
handlers
[
handle
].
reject
(
data
);
}
else
if
(
webClient
.
handlers
[
handle
].
resolve
){
webClient
.
handlers
[
handle
].
resolve
(
data
);
}
delete
webClient
.
handlers
[
handle
];
};
//ロカールDBからルーム一覧情報を取得
...
...
@@ -70,16 +59,20 @@ CHAT_DB.getIosRoomList = function(roomList) {
iosRoomList
=
roomList
;
};
//ロカールDBからログインしたユーザのデータを取得する。
CHAT_DB
.
getMyInfo
=
function
()
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosMyInfo
=
""
;
webkit
.
messageHandlers
.
getMyInfo
.
postMessage
();
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。値の変更を検知してreturn。
return
watchValue
(
iosMyInfo
);
// iosMyInfo = "";
// webkit.messageHandlers.getMyInfo.postMessage();
// return watchValue(iosData, iosMyInfo, onChange);
webClient
.
sendMessage
=
(
data
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
handle
=
'm'
+
webClient
.
id
++
;
webClient
.
handlers
[
handle
]
=
{
resolve
,
reject
};
window
.
webkit
.
messageHandlers
.
getMyInfo
.
postMessage
({
data
:
data
,
id
:
handle
});
});
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getMyInfo
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment